Crawl and Sync Data #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Crawl and Sync Data | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * *' | |
jobs: | |
crawl-and-sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Crawler Repository | |
uses: actions/checkout@v3 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.3 | |
extensions: mbstring, json | |
- name: Update from repository | |
run: | | |
git config --global user.name "Max Base (Actions)" | |
git config --global user.email "maxbasecode+githubactions@gmail.com" | |
- name: Install Dependencies | |
run: composer install || echo "No composer.json found" | |
- name: Run Crawler Scripts | |
run: | | |
php download.php | |
php create-products.php | |
- name: Clone Data Repository | |
run: | | |
git clone https://github.com/BaseMax/buskool.com-data.git data-repo | |
rsync -av --delete data/ data-repo/data/ | |
rsync -av --delete products/ data-repo/products/ | |
cd data-repo | |
git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/BaseMax/buskool.com-data.git data-repo | |
- name: Commit and Push Changes | |
run: | | |
cd data-repo | |
git add . | |
git commit -m "Update data and products from crawler run [${{ github.run_id }}]" || echo "No changes to commit" | |
git push origin main |