Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion .github/actions/check-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ runs:
fi

- name: Check commits for changes in released packages
id: check-release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -77,11 +78,84 @@ runs:
fi

if [ ${#CONFLICTS[@]} -ne 0 ]; then
PACKAGE_NAMES=()

for conflict in "${CONFLICTS[@]}"; do
package_name=$(jq -r ".name" "$conflict/package.json")
PACKAGE_NAMES+=("$package_name")
echo "::error::Release conflict detected in \`$package_name\`. This package is being released in this PR, but files in the package were also modified ahead of this PR. Please ensure that all changes are included in the release."
done
exit 1

PACKAGE_NAMES_JSON=$(printf '%s\n' "${PACKAGE_NAMES[@]}" | jq -R . | jq -s -c .)
echo "package-names=$PACKAGE_NAMES_JSON" >> "$GITHUB_OUTPUT"
echo "has-conflicts=true" >> "$GITHUB_OUTPUT"
else
echo "✅ No release conflicts detected."
fi

- name: Hide previous comments
uses: actions/github-script@v8
env:
PR_NUMBER: ${{ inputs.pull-request }}
with:
script: |
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: process.env.PR_NUMBER,
});

for (const comment of comments) {
if (comment.body.includes('<!-- Pull request release conflict comment -->')) {
await github.graphql(`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is only available through GraphQL for some reason.

mutation($commentId: ID!, $classifier: ReportedContentClassifiers!) {
minimizeComment(input: {subjectId: $commentId, classifier: $classifier}) {
minimizedComment {
isMinimized
}
}
}
`, {
commentId: comment.node_id,
classifier: 'OUTDATED',
});
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Comment Failure Blocks Essential Conflict Communication

The "Hide previous comments" step runs unconditionally without continue-on-error: true, which means if it fails (due to API errors, rate limits, or network issues), the subsequent "Reply on pull request" step won't execute. This prevents users from being notified about release conflicts when the comment-hiding operation fails, causing the workflow to fail with a confusing error about hiding comments rather than the actual conflict.

Fix in Cursor Fix in Web


- name: Reply on pull request
if: steps.check-release.outputs.has-conflicts == 'true'
uses: actions/github-script@v8
env:
PACKAGE_NAMES: ${{ steps.check-release.outputs.package-names }}
PR_NUMBER: ${{ inputs.pull-request }}
with:
script: |
const packageNames = JSON.parse(process.env.PACKAGE_NAMES);
const packageList = packageNames.map(name => `- \`${name}\``).join('\n');

const mergeQueueNote = context.eventName === 'merge_group' ? ' while this pull request was in the merge queue' : '';

const body = `
## Release conflict detected

The following packages are being released in this pull request, but files in these packages were also modified ahead of this pull request${mergeQueueNote}:

${packageList}

Please ensure that all changes are included in the release by updating this pull request, and adjusting the changelogs and version bumps as necessary.

<!-- Pull request release conflict comment -->
`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: process.env.PR_NUMBER,
body: body.split('\n').map(line => line.trim()).join('\n'),
});

- name: Fail if conflicts found
if: steps.check-release.outputs.has-conflicts == 'true'
shell: bash
run: |
exit 1
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
name: Check release
needs: check-workflows
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
Comment on lines +70 to +72
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to be able to leave a comment on pull requests.

steps:
- name: Checkout repository
uses: actions/checkout@v5
Expand Down