Skip to content

feat(publish-preview-oidc): comment on the pull request when publishing fails - #349

Merged
Mrtenz merged 2 commits into
mainfrom
mrtenz/preview-failure-comment
Nov 23, 2026
Merged

Mrtenz merged 2 commits into
mainfrom
mrtenz/preview-failure-comment

Conversation

@Mrtenz

@Mrtenz Mrtenz commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

The publish-preview-oidc workflow only comments on the pull request from the last step of the publish job. When something fails earlier, such as an unknown package name, a build error, a tarball that fails validation, or a polyrepo publish failure, the pull request gets no comment, and whoever ran the workflow has to go and look at the Actions tab.

This adds a comment-on-failure job that depends on the build and publish-preview jobs. It runs when either of them fails and a pull request number is set, and posts a comment with a link to the workflow run. A step at the end of the publish job wouldn't catch build failures, because the publish job is skipped when the build job fails.

The job has only pull-requests: write, has no environment gate, and runs nothing from the pull request. The comment text is fixed, so nothing from the build job ends up in it. Cancelled runs and fork pull requests (where the publish job is skipped) don't get a comment. Partial monorepo failures are already listed in the normal comment.


Note

Low Risk
CI-only change that posts a static failure comment when a PR number is set; no application or publish logic is modified.

Overview
Adds failure feedback to the publish-preview-oidc reusable workflow so PR authors get a comment when preview publishing does not complete successfully.

A new comment-on-failure job runs after build and publish-preview when either job fails and a pull request number was provided. It posts a fixed message with a link to the workflow run, using only pull-requests: write and no environment gate—covering cases where build fails and publish-preview is skipped, which the existing success comment at the end of the publish job never handled.

The unreleased changelog documents the behavior change.

Reviewed by Cursor Bugbot for commit 3067ba9. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a `comment-on-failure` job to `publish-preview-oidc` that posts a link to
the workflow run on the pull request when the build or publish job fails.
Previously, a failure before the final comment step left the pull request with
no comment, so people had to check the Actions tab to find out what happened.
Link the changelog entry for the `comment-on-failure` job to its pull request.
runs-on: ubuntu-latest
steps:
- name: Post failure comment
run: gh pr comment "${PR_NUMBER}" --body "Failed to publish preview builds. [See the workflow run for details](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/attempts/${GITHUB_RUN_ATTEMPT})."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Mrtenz
Mrtenz marked this pull request as ready for review November 23, 2026 11:33
@Mrtenz
Mrtenz merged commit 22b1c8a into main Nov 23, 2026
12 checks passed
@Mrtenz
Mrtenz deleted the mrtenz/preview-failure-comment branch November 23, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants