🔂 Reset Test Repo #121
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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" == "false" ]]; 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 }}" |