Update builder.toml files and Send Pull Request #480
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 builder.toml files and Send Pull Request | |
| on: | |
| schedule: | |
| - cron: '27 2,14 * * *' # daily at 02:27 and 14:27 UTC | |
| workflow_dispatch: {} | |
| concurrency: builder_update | |
| env: | |
| BUILDERS_FILEPATH: "builders.json" | |
| jobs: | |
| preparation: | |
| name: Preparation | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| builders: ${{ steps.get-builders.outputs.builders }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Get Builders | |
| id: get-builders | |
| run: | | |
| builders=$(jq -n -c '[]') | |
| if [ -f ${{ env.BUILDERS_FILEPATH }} ]; then | |
| builders=$(jq -c '.builders' ${{ env.BUILDERS_FILEPATH }}) | |
| else | |
| # Strip off the Github org prefix from repo name | |
| # paketo-buildpacks/builder-with-some-name --> builder-with-some-name | |
| registry_repo=$(echo "${{ github.repository }}" | sed 's/^.*\///') | |
| builders=$(jq -n -c '[ | |
| { | |
| "name": "'"${registry_repo}"'", | |
| "path": ".", | |
| "container_repository": "'"${registry_repo}"'" | |
| } | |
| ]') | |
| fi | |
| # Filter only the necessary fields | |
| builders=$(echo "$builders" | jq 'map({ | |
| name, | |
| path, | |
| container_repository | |
| })') | |
| builders=$(jq -c <<< "$builders") | |
| echo "builders=$builders" | |
| echo "builders=$builders" >> "$GITHUB_OUTPUT" | |
| update: | |
| name: Update builder.toml | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| commit_sha: ${{ steps.commit.outputs.commit_sha }} | |
| needs: preparation | |
| strategy: | |
| max-parallel: 1 | |
| matrix: | |
| builders: ${{ fromJSON(needs.preparation.outputs.builders) }} | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Checkout branch | |
| uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main | |
| with: | |
| branch: "automation/builder-toml-update" | |
| - name: Rebase branch | |
| uses: paketo-buildpacks/github-config/actions/pull-request/rebase-branch@main | |
| with: | |
| keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }} | |
| key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }} | |
| - name: Update builder.toml | |
| uses: paketo-buildpacks/github-config/actions/builder/update@main | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| filename: "${{ matrix.builders.path }}/builder.toml" | |
| - name: Git commit | |
| id: commit | |
| uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main | |
| with: | |
| message: "Update ${{ matrix.builders.name }} builder.toml" | |
| pathspec: "${{ matrix.builders.path }}/builder.toml" | |
| keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }} | |
| key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }} | |
| - name: Git push | |
| if: ${{ steps.commit.outputs.commit_sha != '' }} | |
| uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main | |
| with: | |
| branch: "automation/builder-toml-update" | |
| - name: Output commit sha | |
| if: ${{ steps.commit.outputs.commit_sha != '' }} | |
| run: echo "commit_sha=${{ steps.commit.outputs.commit_sha }}" >> "$GITHUB_OUTPUT" | |
| open-pull-request: | |
| name: Open pull request | |
| runs-on: ubuntu-24.04 | |
| needs: update | |
| if: ${{ needs.update.outputs.commit_sha != '' }} | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Checkout branch | |
| uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main | |
| with: | |
| branch: "automation/builder-toml-update" | |
| - name: Open Pull Request | |
| uses: paketo-buildpacks/github-config/actions/pull-request/open@main | |
| with: | |
| token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | |
| title: "Updating builder.toml files" | |
| branch: "automation/builder-toml-update" | |
| failure: | |
| name: Alert on Failure | |
| runs-on: ubuntu-24.04 | |
| needs: [update, open-pull-request] | |
| if: ${{ always() && ( needs.update.result == 'failure' || needs.open-pull-request.result == 'failure' ) }} | |
| steps: | |
| - name: File Failure Alert Issue | |
| uses: paketo-buildpacks/github-config/actions/issue/file@main | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| repo: ${{ github.repository }} | |
| label: "failure:update-builder-toml" | |
| comment_if_exists: true | |
| issue_title: "Failure: Update Builder TOML workflow" | |
| issue_body: | | |
| Update Builder TOML workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). | |
| comment_body: | | |
| Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |