updater #2896
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: updater | |
| on: | |
| schedule: | |
| - cron: '30 */12 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| diff: ${{ steps.check-versions.outputs.diff }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| check-latest: true | |
| - name: Fetch Dependencies | |
| run: sudo apt install -qq -y jq && npm install | |
| - name: Generate Container Build Info | |
| run: node generator bitmeal/nodegit --node-versions 3 --nodegit-versions 3 > manifest-check.json | |
| - name: Test for new Node or Nodegit versions | |
| id: check-versions | |
| run: diff -q manifest.json manifest-check.json && (echo "No updates") || (echo "New versions detected; check container versions."; echo "diff=true" >> ${GITHUB_OUTPUT}) | |
| check-versions: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| match: ${{ steps.check-containers.outputs.match }} | |
| needs: check-updates | |
| if: needs.check-updates.outputs.diff | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| check-latest: true | |
| - name: Fetch Dependencies | |
| run: sudo apt install -qq -y jq && npm install | |
| - name: Generate Container Build Info | |
| run: node generator bitmeal/nodegit --node-versions 3 --nodegit-versions 3 > manifest-check.json | |
| - name: Test node:alpine container versions against expected node versions | |
| id: check-containers | |
| run: (for version in $(cat manifest-check.json | jq -r '."version-info".node[]'); do (docker pull node:$(echo ${version} | grep -oP '^\d+')-alpine && [ "$(docker run --rm node:$(echo ${version} | grep -oP '^\d+')-alpine node --version)" == "v${version}" ]) && echo "${version} [OK]" || (echo "${version} [FAILED]"; false); done) && (echo "Container node versions match [OK]"; echo "match=true" >> ${GITHUB_OUTPUT}) || (echo "Container node versions DON'T match [FAILED]") | |
| # upload manifest.json only after successful version check | |
| - name: Prepare manifest.json artifact | |
| if: steps.check-containers.outputs.match | |
| run: rm manifest.json && mv manifest-check.json manifest.json | |
| - name: Upload manifest.json artifact | |
| uses: actions/upload-artifact@v3 | |
| if: steps.check-containers.outputs.match | |
| with: | |
| name: manifest.json | |
| path: manifest.json | |
| trigger: | |
| runs-on: ubuntu-latest | |
| needs: check-versions | |
| if: needs.check-versions.outputs.match | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.PUSH_TOKEN }} | |
| - name: Prepare manifest.json | |
| run: rm manifest.json | |
| - name: Fetch manifest.json artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: manifest.json | |
| - name: Push manifest.json and trigger rebuild | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| author_name: update bot | |
| author_email: 41898282+github-actions[bot]@users.noreply.github.com | |
| message: 'Updating manifest; triggering automatic rebuild' | |
| add: 'manifest.json' | |