-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require sha when creating snapshot releases on forks #11794
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a61ffb
Get sha from comment or head
jerelmiller fca0c32
Properly parse sha from comment
jerelmiller 14a5c2b
Tweak name of step
jerelmiller 173f185
Merge branch 'main' into jerel/require-sha-snapshot-release
jerelmiller 30fe414
Switch to env variable to get comment body
jerelmiller 67b413d
Fix formatting
jerelmiller 919808e
Add continue-on-error
jerelmiller 64809a3
Merge branch 'main' into jerel/require-sha-snapshot-release
jerelmiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,21 +33,52 @@ jobs: | |
- uses: alessbell/[email protected] | ||
id: comment-branch | ||
|
||
- name: Checkout head ref | ||
- name: Get sha | ||
id: parse-sha | ||
continue-on-error: true | ||
run: | | ||
if [ "${{ steps.comment-branch.outputs.head_owner }}" == "apollographql" ]; then | ||
echo "sha=${{ steps.comment-branch.outputs.head_sha }}" >> "${GITHUB_OUTPUT}" | ||
else | ||
sha_from_comment="$(echo $COMMENT_BODY | tr -s ' ' | cut -d ' ' -f2)" | ||
|
||
if [ $sha_from_comment == "/release:pr" ]; then | ||
exit 1 | ||
else | ||
echo "sha=$sha_from_comment" >> "${GITHUB_OUTPUT}" | ||
fi | ||
fi | ||
env: | ||
COMMENT_BODY: ${{ github.event.comment.body }} | ||
|
||
- name: Comment sha reminder | ||
if: steps.parse-sha.outcome == 'failure' | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Did you forget to add the sha? Please use `/release:pr <sha>` | ||
|
||
- name: Fail job | ||
if: steps.parse-sha.outcome == 'failure' | ||
run: | | ||
exit 1 | ||
|
||
- name: Checkout ref | ||
uses: actions/checkout@v4 | ||
with: | ||
## specify the owner + repository in order to checkout the fork | ||
## for community PRs | ||
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }} | ||
ref: ${{ steps.comment-branch.outputs.head_ref }} | ||
ref: ${{ steps.parse-sha.outputs.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Detect new changesets | ||
id: added-files | ||
run: | | ||
delimiter="$(openssl rand -hex 8)" | ||
echo "changesets<<${delimiter}" >> "${GITHUB_OUTPUT}" | ||
echo "$(git diff --name-only --diff-filter=A ${{ steps.comment-branch.outputs.base_sha }} ${{ steps.comment-branch.outputs.head_sha }} .changeset/*.md)" >> "${GITHUB_OUTPUT}" | ||
echo "$(git diff --name-only --diff-filter=A ${{ steps.comment-branch.outputs.base_sha }} ${{ steps.parse-sha.outputs.sha }} .changeset/*.md)" >> "${GITHUB_OUTPUT}" | ||
echo "${delimiter}" >> "${GITHUB_OUTPUT}" | ||
|
||
- name: Append NPM token to .npmrc | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between these two
exit 1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I forgot to copy a critical line from my testing. The
Get sha
step should havecontinue-on-error: true
set, which would mean that instead of failing the entire job, it would allow it to continue. The idea was that if it failed, it would add the comment to the PR "Did you forget...", then fail early, hence this step.The other option would be to update every step with
if: steps.parse-sha-outcome != 'failure'
, but that felt like a lot and figured I'd just exit early instead. That plus the job itself would fail rather than succeed in that case so we'd get alerts that way too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added here: https://github.com/apollographql/apollo-client/pull/11794/files#diff-9dc5e53b8fc4bd9d74ca8c2d8d9d5bf7f94c6a8ccc49f2bcc142ec5c171686d1R38