diff --git a/.github/workflows/update-db.yml b/.github/workflows/update-db.yml index d404cf3aae..810179e8ce 100644 --- a/.github/workflows/update-db.yml +++ b/.github/workflows/update-db.yml @@ -1,8 +1,14 @@ -name: Update DB +--- +name: Update on: + pull_request: + branches: [master, nightly] + types: [opened, synchronize, reopened] + push: + branches: [master, nightly] schedule: - - cron: '0 0 * * *' # every day at midnight UTC + - cron: '0 0 * * *' # every day at midnight workflow_dispatch: jobs: @@ -39,11 +45,11 @@ jobs: run: | # empty contents to ensure deleted igdb are removed rm -f -r ./gh-pages/* - + # copy template back to pages cp -f -r ./gh-pages-template/* ./gh-pages/ - - name: Update db + - name: Update working-directory: gh-pages run: | python ../update_db.py \ @@ -51,7 +57,23 @@ jobs: --twitch_client_secret ${{ secrets.TWITCH_CLIENT_SECRET }} \ --youtube_api_key ${{ secrets.YOUTUBE_API_KEY }} + - name: Prepare Artifacts # uploading artifacts will fail if not zipped due to very large quantity of files + shell: bash + if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + run: | + 7z a "./gh-pages.zip" "gh-pages" + + - name: Upload Artifacts + if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + uses: actions/upload-artifact@v3 + with: + name: gh-pages + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + path: | + ${{ github.workspace }}/gh-pages.zip + - name: Deploy to gh-pages + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} # yamllint disable-line rule:line-length uses: actions-js/push@v1.3 with: github_token: ${{ secrets.GH_BOT_TOKEN }}