Update contents.json #282
This file contains hidden or 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: Update contents.json | |
| # Rebuilds contents.json from whatever .wcp assets are published in this repo's | |
| # GitHub Releases, so the catalogue the WinNative app reads is always in sync. | |
| # | |
| # It runs: | |
| # * after every nightly/weekly build workflow finishes (workflow_run) — this is | |
| # what catches new nightlies, because releases created inside a workflow with | |
| # the default GITHUB_TOKEN do NOT raise a `release` event; | |
| # * on `release` events — covers releases created/edited with a PAT or by hand; | |
| # * once daily as a safety net; and on demand. | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_run: | |
| workflows: | |
| - Nightly DXVK | |
| - Nightly VKD3D | |
| - Nightly FEXCore | |
| - Nightly Box64 & WOWBox64 | |
| - Weekly Bundle | |
| types: [completed] | |
| release: | |
| types: [published, released, edited, deleted, unpublished] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: update-contents | |
| cancel-in-progress: false | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Generate contents.json | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: python3 tools/generate_contents.py --source releases --out contents.json | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| if git diff --quiet -- contents.json; then | |
| echo "contents.json already up to date." | |
| exit 0 | |
| fi | |
| git add contents.json | |
| git commit -m "chore: refresh contents.json [skip ci]" | |
| n=0 | |
| until [ "$n" -ge 5 ]; do | |
| git fetch origin main | |
| git rebase origin/main || git rebase --abort | |
| if git push origin HEAD:main; then exit 0; fi | |
| n=$((n + 1)) | |
| sleep 10 | |
| done | |
| exit 1 |