-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (123 loc) · 4.55 KB
/
update-builder-toml.yml
File metadata and controls
143 lines (123 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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}}