-
Notifications
You must be signed in to change notification settings - Fork 6
250 lines (208 loc) · 8.97 KB
/
create-pr.yaml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
---
name: create-pr
on:
workflow_dispatch:
inputs:
run_for:
type: choice
description: What to update
options:
- infra-deployments
- build-definitions
- tenants-config
- all
schedule:
# At 09:00 UTC on Tuesday
- cron: '0 9 * * 2'
permissions:
contents: read
jobs:
create-tenants-config-pr:
if: >
inputs.run_for == 'tenants-config' || inputs.run_for == 'all' || inputs.run_for == ''
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
disable-telemetry: true
# this is the repo we want to update
- name: Checkout tenants-config
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: redhat-appstudio/tenants-config
ref: main
path: tenants-config
- name: Checkout ec-policies
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/ec-policies
ref: main
path: ec-policies
# ./hack/update-infra-deployments.sh ../tenants-config will update any files under tenants-config to the latest release policy
- name: Update policies in tenants-config
run: ./hack/update-infra-deployments.sh ../tenants-config
working-directory: ec-policies
- name: Run kustomize to populate the auto-generated files
run: ./build-manifests.sh
working-directory: tenants-config
# checkout this repo to run create-pr.sh
- name: Checkout infra-deployments-ci
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: infra-deployments-ci
# create-pr.sh changes directory to the upstream tenants-config, creates a remote from the fork and pushes the changes to the fork
- name: Create PR in tenants-config
env:
EC_AUTOMATION_KEY: ${{ secrets.EC_AUTOMATION_KEY }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY_TENANTS_CONFIG }}
APP_INSTALL_ID: 32872589
run: |
set -o errexit
set -o pipefail
set -o nounset
function createJWT() {
local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local now_utc=$(date --utc +%s)
local payload=$(echo -n '{"iat":'$((now_utc - 60))',"exp":'$((now_utc + 120))',"iss":245286}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local signature=$(echo -n "${header}.${payload}" | openssl dgst -sha256 -binary -sign <(echo "${EC_AUTOMATION_KEY}")| base64 | tr -d '\n=' | tr -- '+/' '-_')
echo "${header}.${payload}.${signature}"
}
GITHUB_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $(createJWT)" -H "Accept: application/vnd.github+json" "https://api.github.com/app/installations/${APP_INSTALL_ID}/access_tokens" | jq -r .token) \
./hack/create-pr.sh [email protected]:enterprise-contract/tenants-config.git ../tenants-config
working-directory: infra-deployments-ci
create-infra-deployments-pr:
# also run by default
if: >
inputs.run_for == 'infra-deployments' || inputs.run_for == 'all' || inputs.run_for == ''
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
disable-telemetry: true
- name: Checkout infra-deployments
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: redhat-appstudio/infra-deployments
ref: main
path: infra-deployments
- name: Checkout ec-cli
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/ec-cli
ref: main
path: ec-cli
- name: Update ec-cli
run: ./hack/update-infra-deployments.sh ../infra-deployments
working-directory: ec-cli
- name: Checkout ec-policies
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/ec-policies
ref: main
path: ec-policies
- name: Update ec-policies
run: ./hack/update-infra-deployments.sh ../infra-deployments
working-directory: ec-policies
- name: Checkout enterprise-contract-controller
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/enterprise-contract-controller
ref: main
path: enterprise-contract-controller
- name: Update enterprise-contract-controller
run: ./hack/update-infra-deployments.sh ../infra-deployments
working-directory: enterprise-contract-controller
- name: Checkout ec-config
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/config
ref: main
path: ec-config
- name: Update ec-config
env:
GH_TOKEN: ${{ github.token }}
run: ./hack/update-infra-deployments.sh ../infra-deployments
working-directory: ec-config
- name: Display diff
run: git diff
working-directory: infra-deployments
- name: Checkout infra-deployments-ci
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: infra-deployments-ci
- name: Create PR in infra-deployments
env:
EC_AUTOMATION_KEY: ${{ secrets.EC_AUTOMATION_KEY }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
APP_INSTALL_ID: 32872589
run: |
set -o errexit
set -o pipefail
set -o nounset
function createJWT() {
local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local now_utc=$(date --utc +%s)
local payload=$(echo -n '{"iat":'$((now_utc - 60))',"exp":'$((now_utc + 120))',"iss":245286}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local signature=$(echo -n "${header}.${payload}" | openssl dgst -sha256 -binary -sign <(echo "${EC_AUTOMATION_KEY}")| base64 | tr -d '\n=' | tr -- '+/' '-_')
echo "${header}.${payload}.${signature}"
}
GITHUB_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $(createJWT)" -H "Accept: application/vnd.github+json" "https://api.github.com/app/installations/${APP_INSTALL_ID}/access_tokens" | jq -r .token) \
./hack/create-pr.sh [email protected]:enterprise-contract/infra-deployments.git ../infra-deployments
working-directory: infra-deployments-ci
create-build-definitions-pr:
if: >
inputs.run_for == 'build-definitions' || inputs.run_for == 'all'
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
disable-telemetry: true
- name: Checkout build-definitions
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: redhat-appstudio/build-definitions
ref: main
path: build-definitions
- name: Checkout ec-cli
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: enterprise-contract/ec-cli
ref: main
path: ec-cli
- name: Update ec-cli
env:
KEEP_TAG: 1
run: ./hack/update-build-definitions.sh ../build-definitions
working-directory: ec-cli
- name: Display diff
run: git diff
working-directory: build-definitions
- name: Checkout infra-deployments-ci
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: infra-deployments-ci
- name: Create PR in build-definitions
env:
EC_AUTOMATION_KEY: ${{ secrets.EC_AUTOMATION_KEY }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY_BUILD_DEFINITIONS }}
APP_INSTALL_ID: 32872589
run: |
set -o errexit
set -o pipefail
set -o nounset
function createJWT() {
local header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local now_utc=$(date --utc +%s)
local payload=$(echo -n '{"iat":'$((now_utc - 60))',"exp":'$((now_utc + 120))',"iss":245286}' | base64 | sed s/\+/-/ | sed -E s/=+$//)
local signature=$(echo -n "${header}.${payload}" | openssl dgst -sha256 -binary -sign <(echo "${EC_AUTOMATION_KEY}")| base64 | tr -d '\n=' | tr -- '+/' '-_')
echo "${header}.${payload}.${signature}"
}
GITHUB_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $(createJWT)" -H "Accept: application/vnd.github+json" "https://api.github.com/app/installations/${APP_INSTALL_ID}/access_tokens" | jq -r .token) \
./hack/create-pr.sh [email protected]:enterprise-contract/build-definitions.git ../build-definitions
working-directory: infra-deployments-ci