-
Notifications
You must be signed in to change notification settings - Fork 12
238 lines (212 loc) · 11 KB
/
trigger-cs.yml
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
---
name: CentOS Stream compose trigger
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
- cron: '0 15 * * *'
env:
COMPOSE_URL_CS8: https://odcs.stream.centos.org/stream-8/production
COMPOSE_URL_CS9: https://composes.stream.centos.org/production
jobs:
check-compose:
# Do not run this job on any fork repos
if: github.repository == 'virt-s1/rhel-edge'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check CentOS Stream 8 compose
id: check_compose_id_cs8
run: |
CURRENT_COMPOSE_CS8=$(curl -s "${COMPOSE_URL_CS8}/" | grep -ioE ">CentOS-Stream-8-.*/<" | tr -d '>/<' | tail -1)
curl -s ${COMPOSE_URL_CS8}/${CURRENT_COMPOSE_CS8}/STATUS --output STATUS_CS8
STATUS_CS8=$(cat STATUS_CS8)
if [[ "$STATUS_CS8" == "FINISHED" ]]; then
COMPOSE_ID_CS8=$CURRENT_COMPOSE_CS8
TESTED_COMPOSE_CS8=( $( cat compose/compose.cs8 ) )
if [[ " ${TESTED_COMPOSE_CS8[*]} " =~ "$COMPOSE_ID_CS8" ]]; then
COMPOSE_ID_CS8="false"
fi
else
COMPOSE_ID_CS8="false"
fi
if [[ "$COMPOSE_ID_CS8" != "false" ]]; then
gh pr list -R virt-s1/rhel-edge --state open --json title --jq '.[].title' > PR_LIST_CS8
PR_LIST_CS8=$(cat PR_LIST_CS8)
if [[ $PR_LIST_CS8 == *"$COMPOSE_ID_CS8"* ]]; then
echo "pr_running_cs8=true" >> $GITHUB_OUTPUT
else
echo "pr_running_cs8=false" >> $GITHUB_OUTPUT
fi
OSBUILD_VERSION_CS8=$(curl -s "${COMPOSE_URL_CS8}/${COMPOSE_ID_CS8}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">osbuild-[0-9].*</a" | tr -d "></a")
OSBUILD_COMPOSER_VERSION_CS8=$(curl -s "${COMPOSE_URL_CS8}/${COMPOSE_ID_CS8}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">osbuild-composer-[0-9].*</a" | tr -d "></a")
COMPOSER_CLI_VERSION_CS8=$(curl -s "${COMPOSE_URL_CS8}/${COMPOSE_ID_CS8}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">weldr-client-[0-9].*</a" | tr -d "></a")
echo "osbuild_version_cs8=$OSBUILD_VERSION_CS8" >> $GITHUB_OUTPUT
echo "osbuild_composer_version_cs8=$OSBUILD_COMPOSER_VERSION_CS8" >> $GITHUB_OUTPUT
echo "composer_cli_version_cs8=$COMPOSER_CLI_VERSION_CS8" >> $GITHUB_OUTPUT
else
echo "osbuild_version_cs8=Null" >> $GITHUB_OUTPUT
echo "osbuild_composer_version_cs8=Null" >> $GITHUB_OUTPUT
echo "composer_cli_version_cs8=Null" >> $GITHUB_OUTPUT
fi
echo "cs8_compose=$COMPOSE_ID_CS8" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check CentOS Stream 9 compose
id: check_compose_id_cs9
run: |
CURRENT_COMPOSE_CS9=$(curl -s "${COMPOSE_URL_CS9}/" | grep -ioE ">CentOS-Stream-9-.*/<" | tr -d '>/<' | tail -1)
curl -s ${COMPOSE_URL_CS9}/${CURRENT_COMPOSE_CS9}/STATUS --output STATUS_CS9
STATUS_CS9=$(cat STATUS_CS9)
if [[ "$STATUS_CS9" == "FINISHED" ]]; then
COMPOSE_ID_CS9=$CURRENT_COMPOSE_CS9
TESTED_COMPOSE_CS9=( $( cat compose/compose.cs9 ) )
if [[ " ${TESTED_COMPOSE_CS9[*]} " =~ "$COMPOSE_ID_CS9" ]]; then
COMPOSE_ID_CS9="false"
fi
else
COMPOSE_ID_CS9="false"
fi
if [[ "$COMPOSE_ID_CS9" != "false" ]]; then
gh pr list -R virt-s1/rhel-edge --state open --json title --jq '.[].title' > PR_LIST_CS9
PR_LIST_CS9=$(cat PR_LIST_CS9)
if [[ $PR_LIST_CS9 == *"$COMPOSE_ID_CS9"* ]]; then
echo "pr_running_cs9=true" >> $GITHUB_OUTPUT
else
echo "pr_running_cs9=false" >> $GITHUB_OUTPUT
fi
OSBUILD_VERSION_CS9=$(curl -s "${COMPOSE_URL_CS9}/${COMPOSE_ID_CS9}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">osbuild-[0-9].*<" | tr -d "><")
OSBUILD_COMPOSER_VERSION_CS9=$(curl -s "${COMPOSE_URL_CS9}/${COMPOSE_ID_CS9}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">osbuild-composer-[0-9].*<" | tr -d "><")
COMPOSER_CLI_VERSION_CS9=$(curl -s "${COMPOSE_URL_CS9}/${COMPOSE_ID_CS9}/compose/AppStream/x86_64/os/Packages/" | grep -ioE ">weldr-client-[0-9].*<" | tr -d "><")
echo "osbuild_version_cs9=$OSBUILD_VERSION_CS9" >> $GITHUB_OUTPUT
echo "osbuild_composer_version_cs9=$OSBUILD_COMPOSER_VERSION_CS9" >> $GITHUB_OUTPUT
echo "composer_cli_version_cs9=$COMPOSER_CLI_VERSION_CS9" >> $GITHUB_OUTPUT
else
echo "osbuild_version_cs9=Null" >> $GITHUB_OUTPUT
echo "osbuild_composer_version_cs9=Null" >> $GITHUB_OUTPUT
echo "composer_cli_version_cs9=Null" >> $GITHUB_OUTPUT
fi
echo "cs9_compose=$COMPOSE_ID_CS9" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
cs8_compose: ${{ steps.check_compose_id_cs8.outputs.cs8_compose }}
cs9_compose: ${{ steps.check_compose_id_cs9.outputs.cs9_compose }}
osbuild_version_cs8: ${{ steps.check_compose_id_cs8.outputs.osbuild_version_cs8 }}
osbuild_composer_version_cs8: ${{ steps.check_compose_id_cs8.outputs.osbuild_composer_version_cs8 }}
composer_cli_version_cs8: ${{ steps.check_compose_id_cs8.outputs.composer_cli_version_cs8 }}
osbuild_version_cs9: ${{ steps.check_compose_id_cs9.outputs.osbuild_version_cs9 }}
osbuild_composer_version_cs9: ${{ steps.check_compose_id_cs9.outputs.osbuild_composer_version_cs9 }}
composer_cli_version_cs9: ${{ steps.check_compose_id_cs9.outputs.composer_cli_version_cs9 }}
pr_running_cs8: ${{ steps.check_compose_id_cs8.outputs.pr_running_cs8 }}
pr_running_cs9: ${{ steps.check_compose_id_cs9.outputs.pr_running_cs9 }}
centos-stream-8:
needs: check-compose
if: ${{ needs.check-compose.outputs.cs8_compose != 'false' && needs.check-compose.outputs.pr_running_cs8 == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add new compose id in compose.cs8
run: |
compose_id="${{ needs.check-compose.outputs.cs8_compose }}"
echo $compose_id >> compose/compose.cs8
cat compose/compose.cs8
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "${{ needs.check-compose.outputs.cs8_compose }} - ${{ steps.date.outputs.date }}"
committer: cloudkitebot <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: cpr
branch-suffix: random
delete-branch: true
title: "${{ needs.check-compose.outputs.cs8_compose }} - ${{ steps.date.outputs.date }}"
labels: auto-merge,CentOS-Stream-8
body: |
CentOS Stream 8 compose ${{ needs.check-compose.outputs.cs8_compose }}
- Date: ${{ steps.date.outputs.date }}
- Compose URL: "${{ env.COMPOSE_URL_CS8 }}/${{ needs.check-compose.outputs.cs8_compose }}"
- Packages:
- ${{ needs.check-compose.outputs.osbuild_version_cs8 }}
- ${{ needs.check-compose.outputs.osbuild_composer_version_cs8 }}
- ${{ needs.check-compose.outputs.composer_cli_version_cs8 }}
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: rebase
- name: Add a comment to trigger test workflow
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.PAT }}
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
body: /test-cs8
- name: Create a project card to track compose test result
uses: peter-evans/create-or-update-project-card@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
project-name: RHEL Compose Test
column-name: CentOS-Stream-8
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
centos-stream-9:
needs: check-compose
if: ${{ needs.check-compose.outputs.cs9_compose != 'false' && needs.check-compose.outputs.pr_running_cs9 == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add new compose id in compose.cs9
run: |
compose_id="${{ needs.check-compose.outputs.cs9_compose }}"
echo $compose_id >> compose/compose.cs9
cat compose/compose.cs9
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "${{ needs.check-compose.outputs.cs9_compose }} - ${{ steps.date.outputs.date }}"
committer: cloudkitebot <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: cpr
branch-suffix: random
delete-branch: true
title: "${{ needs.check-compose.outputs.cs9_compose }} - ${{ steps.date.outputs.date }}"
labels: auto-merge,CentOS-Stream-9
body: |
CentOS Stream 9 compose ${{ needs.check-compose.outputs.cs9_compose }}
- Date: ${{ steps.date.outputs.date }}
- Compose URL: "${{ env.COMPOSE_URL_CS9 }}/${{ needs.check-compose.outputs.cs9_compose }}"
- Packages:
- ${{ needs.check-compose.outputs.osbuild_version_cs9 }}
- ${{ needs.check-compose.outputs.osbuild_composer_version_cs9 }}
- ${{ needs.check-compose.outputs.composer_cli_version_cs9 }}
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: rebase
- name: Add a comment to trigger test workflow
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.PAT }}
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
body: /test-cs9
- name: Create a project card to track compose test result
uses: peter-evans/create-or-update-project-card@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
project-name: RHEL Compose Test
column-name: CentOS-Stream-9
issue-number: ${{ steps.cpr.outputs.pull-request-number }}