-
Notifications
You must be signed in to change notification settings - Fork 6
182 lines (152 loc) · 6.19 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
---
name: create-pr
on:
workflow_dispatch:
inputs:
run_for:
type: choice
description: What to update
options:
- infra-deployments
- build-definitions
- all
schedule:
# At 09:00 UTC on Tuesday
- cron: '0 9 * * 2'
permissions:
contents: read
jobs:
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@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
disable-telemetry: true
- name: Checkout infra-deployments
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: redhat-appstudio/infra-deployments
ref: main
path: infra-deployments
- name: Checkout ec-cli
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
disable-telemetry: true
- name: Checkout build-definitions
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: konflux-ci/build-definitions
ref: main
path: build-definitions
- name: Checkout ec-cli
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
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