|
| 1 | +name: Assemble tools.json |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'master', 'main' ] |
| 6 | + paths: |
| 7 | + - "tools/*" |
| 8 | + - ".github/workflows/assemble_tools_json.yml" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token |
| 12 | +permissions: { } |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + assemble: |
| 20 | + name: assemble tools.json |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v5 |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: 3.x |
| 29 | + - name: assemble tools.json |
| 30 | + run: helpers/tools-assemble.py |
| 31 | + - name: Upload artifact |
| 32 | + uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: tools.json |
| 35 | + path: tools.json |
| 36 | + |
| 37 | + validate: |
| 38 | + needs: |
| 39 | + - assemble |
| 40 | + name: validate tools.json |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@v5 |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: 3.x |
| 49 | + - name: Install check-jsonschema |
| 50 | + run: pip install check-jsonschema |
| 51 | + - name: Download artifact |
| 52 | + uses: actions/download-artifact@v5 |
| 53 | + with: |
| 54 | + name: tools.json |
| 55 | + - name: Validate tools.json |
| 56 | + run: check-jsonschema --schemafile schemas/tools.schema.json tools.json |
| 57 | + |
| 58 | + push-back: |
| 59 | + needs: |
| 60 | + - assemble |
| 61 | + - validate |
| 62 | + name: push tools.json |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: write # needed for git push |
| 66 | + steps: |
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@v5 |
| 69 | + with: |
| 70 | + ref: ${{ github.head_ref }} |
| 71 | + - name: Download artifact |
| 72 | + uses: actions/download-artifact@v5 |
| 73 | + with: |
| 74 | + name: tools.json |
| 75 | + - name: diff |
| 76 | + run: git diff tools.json |
| 77 | + - name: Configure Git |
| 78 | + run: | |
| 79 | + git config user.name "github-actions[bot]" |
| 80 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 81 | + - name: Commit tools.json |
| 82 | + run: | |
| 83 | + git add tools.json |
| 84 | + git commit -s -m "Update tools.json [automated commit]" || echo "No changes to commit" |
| 85 | + - name: git push back |
| 86 | + run: git push |
| 87 | + |
| 88 | + publish: |
| 89 | + needs: |
| 90 | + - push-back |
| 91 | + # need to trigger this workflow manually, for the following reason: |
| 92 | + # The "publish" workflow is triggered whenever a `tools.json` is modified - which happens during |
| 93 | + # the `push-back` step. and this commit is issued by a bot. |
| 94 | + # GitHub workflows may triggered on events only if not issues by a bot - so the workflow would |
| 95 | + # not trigger automatically. |
| 96 | + uses: .github/workflows/publish_toolcenter.yml |
0 commit comments