-
Notifications
You must be signed in to change notification settings - Fork 0
400 lines (310 loc) · 16.5 KB
/
reset_test_repo.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name: 🔂 Reset Test Repo
on:
workflow_dispatch:
env:
TARGET_REPO: "ynput/ayon-addon-action-testing"
TARGET_REPO_PROJECT_NAME: "action-testing"
DEFAULT_BRANCH: "develop"
MAIN_BRANCH: main
TEMPLATE_REPO: "ynput/ayon-addon-template"
GH_TOKEN: ${{ secrets.REPO_CTRL_TOKEN }}
REQUIRED_SECRECTS: CI_EMAIL,CI_USER,REPO_CTRL_TOKEN,YNPUT_BOT_TOKEN
jobs:
verify_repo_secrets:
runs-on: ubuntu-latest
steps:
- name: 🔎 Verify repo secrets for ${{ github.repository }}
id: verify_var
run: |
missing_vars=$(echo ${{ env.REQUIRED_SECRECTS }} | tr ',' '\n' | while read var; do
gh secret list --repo ${{ github.repository }} --json name --jq '.[].name' | grep -qx "$var" || echo "$var"
done)
if [ -n "$missing_vars" ]; then
echo "::error::The following required variables are missing: $missing_vars for repository ${{ github.repository }}"
exit 1
else
echo "::notice::All required variables are present."
fi
reset-test-repo:
runs-on: ubuntu-latest
needs: verify_repo_secrets
steps:
# TODO Implement early return to check if all required repo variables exist
# TODO Implement early return to check against list of testing repos
- name: Check for existing repo
id: repo-check
run: |
if ! gh repo view "${{ env.TARGET_REPO }}" > /dev/null 2>&1; then
echo "::error::Repository `${{ env.TARGET_REPO }}` doesn't exists - can't reset. Please create the repository first."
echo "repo_present=false" >> $GITHUB_OUTPUT
exit 1
fi
echo "repo_present=true" >> $GITHUB_OUTPUT
echo "::notice::Found Repository ${{ env.TARGET_REPO }}."
exit 0
- name: Delete repository if exists
if: steps.repo-check.outputs.repo_present
run: |
echo "::notice:: Deleting repository `${{ env.TARGET_REPO }}`"
gh repo delete "${{ env.TARGET_REPO }}" --yes
- name: Create new Repo `${{ env.TARGET_REPO }}` from template `${{ env.TEMPLATE_REPO }}`
run: |
gh repo create ${{ env.TARGET_REPO }} --template ${{ env.TEMPLATE_REPO }} --public
echo "::notice::Recreated repository `${{ env.TARGET_REPO }}` from template `${{ env.TEMPLATE_REPO }}`"
- name: Show branches
run: |
gh api repos/${{ env.TARGET_REPO }}/branches --jq '.[].name'
prepare-repo:
runs-on: ubuntu-latest
needs: reset-test-repo
env:
DEFAULT_BRANCH: "develop"
steps:
- name: Add ${{ github.actor }} as repo collaborator
# WARNING critical step - user will loose admin-permission in repo if step is removed or altered incorrect
if: always()
run: |
gh api --method PUT \
-H "Accept: application/vnd.github.v3+json" \
"/repos/${{ env.TARGET_REPO }}/collaborators/${{ github.actor }}" \
-f permission=admin
- name: Set repo secrets
# INFO deprecated - should be set from organization
run: |
# gh secret set YNPUT_BOT_TOKEN --body "${{ secrets.YNPUT_BOT_TOKEN }}" --repo ${{ env.TARGET_REPO }}
# gh secret set CI_USER --body "${{ secrets.CI_USER }}" --repo ${{ env.TARGET_REPO }}
# gh secret set CI_EMAIL --body "${{ secrets.CI_EMAIL }}" --repo ${{ env.TARGET_REPO }}
echo "$(gh secret list --repo ${{ env.TARGET_REPO }})"
- name: Set repo description and topic
run: |
gh repo edit "${{ env.TARGET_REPO }}" --description "Repository for automated action testing"
gh repo edit "${{ env.TARGET_REPO }}" --add-topic testing
- name: Set repo variables
run: |
gh variable set PATCH_BUMP_LABEL --body "type: bugfix" --repo ${{ env.TARGET_REPO }}
gh variable set MINOR_BUMP_LABEL --body "type: feature, type: enhancement" --repo ${{ env.TARGET_REPO }}
gh variable set MAIN_BRANCH --body "main" --repo ${{ env.TARGET_REPO }}
gh variable set PROJECT_NAME --body ${{ env.TARGET_REPO_PROJECT_NAME }} --repo ${{ env.TARGET_REPO }}
gh variable set CHANGELOG_ORDER --body "type: feature(🎉),type: enhancement(💚),type: bugfix(🐛),refactor,docs,test,pr" --repo ${{ env.TARGET_REPO }}
echo "$(gh variable list --repo ${{ env.TARGET_REPO }})"
- name: Add repo labels
run: |
gh label create "type: feature" --color "#008672" --description "New functionality which is not present so far" --repo ${{ env.TARGET_REPO }}
gh label create "type: enhancement" --color "#b9f29d" --description "Something got fixed" --repo ${{ env.TARGET_REPO }}
gh label create "type: bugfix" --color "#f96713" --description "Something got fixed" --repo ${{ env.TARGET_REPO }}
echo "$(gh label list --repo ${{ env.TARGET_REPO }})"
local-changes:
runs-on: ubuntu-latest
needs: prepare-repo
steps:
- name: Checkout ${{ env.TARGET_REPO }} repo
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
repository: ${{ env.TARGET_REPO }}
ref: ${{ env.DEFAULT_BRANCH }}
- name: Add PR Template
# TODO change develop to main
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/.github/pull_request_template.md
mv pull_request_template.md ./.github/pull_request_template.md
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git add ./.github/pull_request_template.md
git commit -m "Add pr template"
git push origin ${{ env.DEFAULT_BRANCH }}
- name: Add initial-release workflow
# TODO change branch to main
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository }}/refactor-release-workflow-structure/caller_workflows/addon_repo_initial_release.yml
mv addon_repo_initial_release.yml ./.github/workflows/initial_release.yml
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git add ./.github/workflows/initial_release.yml
git commit -m "Add initial release trigger workflow"
git push origin ${{ env.DEFAULT_BRANCH }}
- name: Add release workflow
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository }}/refactor-release-workflow-structure/caller_workflows/addon_repo_release_trigger.yml
mv addon_repo_release_trigger.yml ./.github/workflows/release_trigger.yml
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git add ./.github/workflows/release_trigger.yml
git commit -m "Add release trigger workflow"
git push origin ${{ env.DEFAULT_BRANCH }}
- name: Add pr-to-project caller workflow
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/caller_workflows/assign-pr-to-project.yml
mv assign-pr-to-project.yml ./.github/workflows/assign-pr-to-project.yml
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git add ./.github/workflows/assign-pr-to-project.yml
git commit -m "Add pr-to-project workflow"
git push origin ${{ env.DEFAULT_BRANCH }}
- name: 🗒️ Adjust package.py
run: |
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
# INFO capitalize all letters after a "-" and the first one
repo_name_cap=$(echo "${{ env.TARGET_REPO_PROJECT_NAME }}" | sed -E 's/(^|-)(.)/\1\U\2/g')
sed -i "s/^version = \".*\"/version = \"0.1.0\"/" package.py
sed -i "s/^name = \".*\"/name = \"${{ env.TARGET_REPO_PROJECT_NAME }}\"/" package.py
sed -i "s/^title = \".*\"/title = \"$repo_name_cap\"/" package.py
git add package.py
git commit -m "Add warning information to readme."
git push origin ${{ env.DEFAULT_BRANCH }}
- name: 🗒️ Adjust readme
run: |
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
echo -e "# Not intended for Development\nThis is a testing repository for github actions.<br>Changes in this repository are likely to be reset by automanted testing procedures.<br>Don't use this repository for any development - use [ynput/ci-testing](https://github.com/ynput/ci-testing) instead." > README.md
git add README.md
git commit -m "Add warning information to readme"
git push origin ${{ env.DEFAULT_BRANCH }}
update-repo:
runs-on: ubuntu-latest
needs: local-changes
steps:
- name: Get latest sha from ${{ env.DEFAULT_BRANCH }}
id: latest-sha
run: |
commit_sha=$(gh api /repos/${{ env.TARGET_REPO }}/branches/develop -q '.commit.sha')
echo "sha=$commit_sha" >> $GITHUB_OUTPUT
- name: Add main branch
run: |
gh api \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/${{ env.TARGET_REPO }}/git/refs \
-f ref="refs/heads/${{ env.MAIN_BRANCH }}" \
-f sha="${{ steps.latest-sha.outputs.sha }}"
# TODO renable as soon as Teama ctor ID works again
# - name: Update protect_main.json file
# # TODO change develop to main
# run: |
# curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/branch_rules/protect_main.json
# cat protect_main.json | jq '.bypass_actors[0].actor_id = ${{ secrets.ACTOR_ID_TEAM }}' > protect_main_insert.json
# - name: Apply ruleset for '${{ env.MAIN_BRANCH }}'
# run: |
# gh api \
# --method POST \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/${{ env.TARGET_REPO }}/rulesets \
# --input protect_main_insert.json
# - name: Update protect_develop.json file
# # TODO change develop to main
# run: |
# curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/branch_rules/protect_develop.json
# cat protect_develop.json | jq '.bypass_actors[0].actor_id = ${{ secrets.ACTOR_ID_REPO_ROLE }} | .bypass_actors[1].actor_id = ${{ secrets.ACTOR_ID_TEAM }} | .bypass_actors[2].actor_id = ${{ secrets.ACTOR_ID_ORG_ADMIN }}' > protect_develop_insert.json
# - name: Apply ruleset for 'develop'
# run: |
# gh api \
# --method POST \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/${{ env.TARGET_REPO }}/rulesets \
# --input protect_develop_insert.json
prepare-release:
runs-on: ubuntu-latest
needs: update-repo
steps:
- name: Create GitHub Release
run: |
gh workflow run initial_release.yml --repo ${{ env.TARGET_REPO }} --field draft=false
- name: Poll for Draft Release
# TODO check if draft release creation emmits a signal or something to avoid this kind of pulling
id: poll-release
run: |
for i in {1..20}; do
DRAFT_RELEASE=$(gh release list --repo ${{ env.TARGET_REPO }} --limit 1 --json isDraft --jq '.[0].isDraft')
if [[ "$DRAFT_RELEASE" == "true" ]]; then
echo "Draft release found."
release_tag=$(gh release list --repo ${{ env.TARGET_REPO }} --limit 1 --json tagName --jq '.[0].tagName')
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
break
else
echo "Draft release not found yet, retrying in 15 seconds..."
sleep 15
fi
done
create-dummy-prs:
runs-on: ubuntu-latest
needs: prepare-release
steps:
- name: Checkout ${{ env.TARGET_REPO }} repo
uses: actions/checkout@v4
with:
token: ${{ env.GH_TOKEN }}
repository: ${{ env.TARGET_REPO }}
ref: ${{ env.DEFAULT_BRANCH }}
- name: Create first feature branch
run: |
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git checkout -b test_feature01
date >> date.txt
git add date.txt
git commit -m "Add date file"
git push -u origin test_feature01
pr_body="
## Changelog Description
Add temp directory for deadline submission so that it would not error out during deadline submission.
Continuity of https://github.com/ynput/ayon-blender/pull/17
*Support different system platform
## Additional info
n/a
## Testing notes:
1. Launch Blender
2. Create Render Instance
3. Publish
4. If validate render output for deadline errors out, make sure you perform repair action
5. Publish
6. It should be rendered successfully.
## Changelog Description
Add temp directory for deadline submission so that it would not error out during deadline submission.
Continuity of https://github.com/ynput/ayon-blender/pull/17
*Support different system platform
## Additional info
n/a
## Testing notes:
1. Launch Blender
2. Create Render Instance
3. Publish
4. If validate render output for deadline errors out, make sure you perform repair action
5. Publish
6. It should be rendered successfully.
"
gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature01 --title "Add date file" --body "$pr_body" --label "type: bugfix" --assignee "${{ github.actor }}"
- name: Create second feature branch
run: |
git config --global user.name "${{ secrets.CI_USER }}"
git config --global user.email "${{ secrets.CI_EMAIL }}"
git checkout -b test_feature02
free -h >> memory_usage.txt
git add memory_usage.txt
git commit -m "Add memory usage file"
git push -u origin test_feature02
pr_body="
## Changelog Description
<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->
- Prototype loading of USD references into a Maya USD proxy while keeping it managed by the pipeline
- Prototype loading of Maya references into a Maya USD proxy while keeping it managed by the pipeline
## Additional info
<!-- Paragraphs of text giving context of additional technical information or code examples. -->
Separated from #2
## Testing notes:
1. Loading of the USD data should work as intended into Maya USD Proxy Shapes.
2. Managing (updating) and removal via scene inventory should also do what is expected.
## Changelog Description
<!-- Paragraphs contain detailed information on the changes made to the product or service, providing an in-depth description of the updates and enhancements. They can be used to explain the reasoning behind the changes, or to highlight the importance of the new features. Paragraphs can often include links to further information or support documentation. -->
- Prototype loading of USD references into a Maya USD proxy while keeping it managed by the pipeline
- Prototype loading of Maya references into a Maya USD proxy while keeping it managed by the pipeline
## Additional info
<!-- Paragraphs of text giving context of additional technical information or code examples. -->
Separated from #2
## Testing notes:
1. Loading of the USD data should work as intended into Maya USD Proxy Shapes.
2. Managing (updating) and removal via scene inventory should also do what is expected.
"
gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature02 --title "Add mem file" --body "$pr_body" --label "type: enhancement" --assignee "${{ github.actor }}"