File tree Expand file tree Collapse file tree 5 files changed +94
-57
lines changed
Expand file tree Collapse file tree 5 files changed +94
-57
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ permissions:
1010
1111jobs :
1212 github-action :
13+ if : " !startsWith(github.event.name , 'v0.0.0-test-')" # Do not run for test releases created by test-include.yml and test-exclude.yml
1314 uses : cloudposse-github-actions/.github/.github/workflows/shared-release-branches.yml@main
1415 secrets : inherit
Original file line number Diff line number Diff line change 1+ name : Test Excluded Regex
2+ on :
3+ pull_request : {}
4+
5+ jobs :
6+ setup :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - name : Setup
10+ run : echo "Do setup"
11+
12+ test :
13+ runs-on : ubuntu-latest
14+ continue-on-error : true
15+ needs : [setup]
16+ steps :
17+ - name : Checkout
18+ uses : actions/checkout@v3
19+
20+ - id : sha-short
21+ run : echo "result=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
22+
23+ # Below is the only difference between test-include.yml (the positive counterpart of this workflow).
24+ # test-release.yml will not pick up this comment because include_regex will only match a 'v0.0.0-test-include' prefix.
25+ - run : gh release create v0.0.0-test-exclude.${{ steps.sha-short.outputs.result }} --prerelease --target ${{ github.sha }} --notes "Prerelease used for tests (will be automatically deleted)."
26+ env :
27+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
28+
29+ outputs :
30+ release : v0.0.0-test-exclude.${{ steps.sha-short.outputs.result }}
31+
32+ assert :
33+ runs-on : ubuntu-latest
34+ needs : [test]
35+ timeout-minutes : 5 # Timeout for test release workflow to run
36+ steps :
37+ - run : |
38+ # Wait until a release workflow whose tag is tied to this PR's SHA is running
39+ while [[ $(gh run list -w "Test Release" --json databaseId -q 'length' -s completed -c ${{ github.sha }}) -eq 0 ]]; do
40+ sleep 5
41+ done
42+ env:
43+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
45+ - name : Find Comment (should fail)
46+ uses : peter-evans/find-comment@v3
47+ id : fc
48+ continue-on-error : true
49+ with :
50+ issue-number : ${{ github.event.pull_request.number }}
51+ body-regex : " ^These changes were released in .*${{ needs.test.outputs.release }}.*$"
52+
53+ - name : Assert Comment Not Found
54+ if : steps.fc.outcome != 'success'
55+ run : exit 0
56+
57+ teardown :
58+ runs-on : ubuntu-latest
59+ needs : [test, assert]
60+ if : ${{ always() }}
61+ steps :
62+ - run : gh release delete ${{ needs.test.outputs.release }}
63+ env :
64+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1- name : Test Positive
1+ name : Test Included Regex
22on :
33 pull_request : {}
44
@@ -20,23 +20,27 @@ jobs:
2020 - id : sha-short
2121 run : echo "result=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
2222
23- - run : gh release create v0.0.0-test.${{ steps.sha-short.outputs.result }} --prerelease --target ${{ github.sha }} --notes "Prerelease used for tests (will be automatically deleted)."
23+ - run : gh release create v0.0.0-test-include .${{ steps.sha-short.outputs.result }} --prerelease --target ${{ github.sha }} --notes "Prerelease used for tests (will be automatically deleted)."
2424 env :
2525 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2626
27- - uses : ./
28- id : current
29- with :
30- include_regex : " /v0\\ .0\\ .0-test\\ .*./g"
31-
3227 outputs :
33- release : v0.0.0-test.${{ steps.sha-short.outputs.result }}
28+ release : v0.0.0-test-include .${{ steps.sha-short.outputs.result }}
3429
3530 assert :
3631 runs-on : ubuntu-latest
3732 needs : [test]
33+ timeout-minutes : 5 # Timeout for test release workflow to run
3834 steps :
39- - name : Find Comment
35+ - run : |
36+ # Wait until a release workflow whose tag is tied to this PR's SHA is running
37+ while [[ $(gh run list -w "Test Release" --json databaseId -q 'length' -s completed -c ${{ github.sha }}) -eq 0 ]]; do
38+ sleep 5
39+ done
40+ env:
41+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+ - name : Find Comment (should pass)
4044 uses : peter-evans/find-comment@v3
4145 id : fc
4246 with :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ name : Test Release
2+ on :
3+ release :
4+ types : [published]
5+
6+ permissions :
7+ id-token : write
8+ contents : write
9+ pull-requests : write
10+
11+ jobs :
12+ pr-comment-on-release :
13+ if : " startsWith(github.event.name , 'v0.0.0-test')" # Match only releases created by test-include.yml and test-exclude.yml
14+ uses : ./action.yaml
15+ with :
16+ include_regex : " /v0\\ .0\\ .0-test-include\\ .*./g" # Only include releases created by test-include.yml
You can’t perform that action at this time.
0 commit comments