-
-
Notifications
You must be signed in to change notification settings - Fork 256
ci: Add comment with explanation when a release conflict is detected #7162
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ runs: | |
| fi | ||
|
|
||
| - name: Check commits for changes in released packages | ||
| id: check-release | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
|
@@ -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(` | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
| }); | ||
| } | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Comment Failure Blocks Essential Conflict CommunicationThe "Hide previous comments" step runs unconditionally without |
||
|
|
||
| - 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'), | ||
| }); | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Fail if conflicts found | ||
| if: steps.check-release.outputs.has-conflicts == 'true' | ||
| shell: bash | ||
| run: | | ||
| exit 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.