diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 04a7795fcad..6020dddee7d 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -33,13 +33,44 @@ jobs: - uses: alessbell/pull-request-comment-branch@v2.1.0 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/create-or-update-comment@v2.1.0 + with: + issue-number: ${{ github.event.issue.number }} + body: | + Did you forget to add the sha? Please use `/release:pr ` + + - 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 @@ -47,7 +78,7 @@ jobs: 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