|
| 1 | +name: Update tooling submodule on new release |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [tooling-release] |
| 6 | + |
| 7 | +jobs: |
| 8 | + update-submodule: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + if: github.repository_owner == 'SMPTE' |
| 11 | + |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout template repo with submodule |
| 17 | + uses: actions/checkout@v3 |
| 18 | + with: |
| 19 | + token: ${{ secrets.SUBMODULE_UPDATE_PAT }} |
| 20 | + submodules: true |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Check if submodule is already at this SHA |
| 24 | + id: check |
| 25 | + env: |
| 26 | + TARGET_SHA: ${{ github.event.client_payload.sha }} |
| 27 | + run: | |
| 28 | + CURRENT_SHA=$(git -C tooling rev-parse HEAD) |
| 29 | + echo "current_sha=${CURRENT_SHA}" >> "$GITHUB_OUTPUT" |
| 30 | + if [[ "$CURRENT_SHA" == "$TARGET_SHA" ]]; then |
| 31 | + echo "already_up_to_date=true" >> "$GITHUB_OUTPUT" |
| 32 | + else |
| 33 | + echo "already_up_to_date=false" >> "$GITHUB_OUTPUT" |
| 34 | + fi |
| 35 | +
|
| 36 | + - name: Update submodule to release SHA |
| 37 | + if: steps.check.outputs.already_up_to_date != 'true' |
| 38 | + env: |
| 39 | + TARGET_SHA: ${{ github.event.client_payload.sha }} |
| 40 | + run: | |
| 41 | + git -C tooling fetch origin |
| 42 | + git -C tooling checkout "$TARGET_SHA" |
| 43 | +
|
| 44 | + - name: Commit and push to main |
| 45 | + if: steps.check.outputs.already_up_to_date != 'true' |
| 46 | + env: |
| 47 | + TAG: ${{ github.event.client_payload.tag }} |
| 48 | + TARGET_SHA: ${{ github.event.client_payload.sha }} |
| 49 | + CURRENT_SHA: ${{ steps.check.outputs.current_sha }} |
| 50 | + run: | |
| 51 | + git config user.name "github-actions[bot]" |
| 52 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 53 | + git add tooling |
| 54 | + git commit -m "bump tooling to ${TAG} |
| 55 | +
|
| 56 | + Updates tooling submodule from ${CURRENT_SHA} to ${TARGET_SHA}." |
| 57 | + git push origin main |
0 commit comments