Skip to content

Commit 52dc8eb

Browse files
jerelmillerphryneasalessbell
authored
Require sha in snapshot releases for forks (#292)
* Update snapshot release workflow to require sha in forks * Update .github/workflows/snapshot-release.yml Co-authored-by: Alessia Bellisario <[email protected]> --------- Co-authored-by: Lenz Weber-Tronic <[email protected]> Co-authored-by: Alessia Bellisario <[email protected]>
1 parent 0aca825 commit 52dc8eb

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

.github/workflows/snapshot-release.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
if: |
1515
github.repository == 'apollographql/apollo-client-nextjs' &&
1616
(
17-
github.event_name == 'workflow_dispatch' ||
17+
github.event_name == 'workflow_dispatch' ||
1818
(
1919
github.event.issue.pull_request &&
2020
(
@@ -33,14 +33,46 @@ jobs:
3333
if: github.event_name == 'issue_comment'
3434
id: comment-branch
3535

36+
- name: Get sha
37+
if: github.event_name == 'issue_comment'
38+
id: parse-sha
39+
continue-on-error: true
40+
run: |
41+
if [ "${{ steps.comment-branch.outputs.head_owner }}" == "apollographql" ]; then
42+
echo "sha=${{ steps.comment-branch.outputs.head_sha }}" >> "${GITHUB_OUTPUT}"
43+
else
44+
sha_from_comment="$(echo $COMMENT_BODY | tr -s ' ' | cut -d ' ' -f2)"
45+
46+
if [ $sha_from_comment == "/release:pr" ]; then
47+
exit 1
48+
else
49+
echo "sha=$sha_from_comment" >> "${GITHUB_OUTPUT}"
50+
fi
51+
fi
52+
env:
53+
COMMENT_BODY: ${{ github.event.comment.body }}
54+
55+
- name: Comment sha reminder
56+
if: steps.parse-sha.outcome == 'failure'
57+
uses: peter-evans/[email protected]
58+
with:
59+
issue-number: ${{ github.event.issue.number }}
60+
body: |
61+
Did you forget to add the sha? Please use `/release:pr <sha>`
62+
63+
- name: Fail job
64+
if: steps.parse-sha.outcome == 'failure'
65+
run: |
66+
exit 1
67+
3668
- name: Checkout head ref (comment trigger)
3769
if: github.event_name == 'issue_comment'
3870
uses: actions/checkout@v4
3971
with:
4072
## specify the owner + repository in order to checkout the fork
4173
## for community PRs
4274
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }}
43-
ref: ${{ steps.comment-branch.outputs.head_ref }}
75+
ref: ${{ steps.parse-sha.outputs.sha }}
4476
fetch-depth: 0
4577

4678
- name: Checkout head ref (dispatch trigger)

0 commit comments

Comments
 (0)