-
Notifications
You must be signed in to change notification settings - Fork 29
Revert "ref: Remove #retract command" #7292
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 | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | |||||||||||||||||||||||||||||
| name: Retract Release | |||||||||||||||||||||||||||||
| on: | |||||||||||||||||||||||||||||
| issue_comment: | |||||||||||||||||||||||||||||
| types: [created] | |||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
| retract: | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| name: Retract a release | |||||||||||||||||||||||||||||
| # not a pull request and has `#contains` on a line by itself | |||||||||||||||||||||||||||||
| # fromJSON is used to process escape sequences | |||||||||||||||||||||||||||||
| if: | | |||||||||||||||||||||||||||||
| !github.event.issue.pull_request && | |||||||||||||||||||||||||||||
| contains( | |||||||||||||||||||||||||||||
| format(fromJSON('"\n{0}\n"'), github.event.comment.body), | |||||||||||||||||||||||||||||
| fromJSON('"\n#retract\n"') | |||||||||||||||||||||||||||||
| ) | |||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Get repo contents | |||||||||||||||||||||||||||||
| uses: actions/checkout@v6 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| path: .__publish__ | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Setup Node | |||||||||||||||||||||||||||||
| uses: actions/setup-node@v6 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| node-version: 24 | |||||||||||||||||||||||||||||
| cache: yarn | |||||||||||||||||||||||||||||
| cache-dependency-path: .__publish__/yarn.lock | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Install yarn dependencies | |||||||||||||||||||||||||||||
| run: yarn install --cwd ".__publish__" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Parse and set inputs | |||||||||||||||||||||||||||||
| id: inputs | |||||||||||||||||||||||||||||
| run: node .__publish__/src/publish/inputs.js | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Comment and close | |||||||||||||||||||||||||||||
| if: ${{ fromJSON(steps.inputs.outputs.result).requester == github.event.sender.login }} | |||||||||||||||||||||||||||||
|
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: The Suggested FixModify the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
|||||||||||||||||||||||||||||
| env: | |||||||||||||||||||||||||||||
| PUBLISH_ARGS: ${{ steps.inputs.outputs.result }} | |||||||||||||||||||||||||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |||||||||||||||||||||||||||||
| run: node .__publish__/src/publish/retract.js | |||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+42
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 28 days ago In general, the fix is to explicitly declare a For this specific workflow, the job checks out the repository ( permissions:
contents: readindented correctly between the
Suggested changeset
1
.github/workflows/retract.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { vi, describe, test, expect } from "vitest"; | ||
|
|
||
| vi.mock("fs"); | ||
|
|
||
| const retractRelease = require("../retract-release.js"); | ||
|
|
||
| describe("retract release", () => { | ||
| test("comment and close issue", async () => { | ||
| const retractArgs = { | ||
| inputs: { repo: "sentry", version: "21.3.1" }, | ||
| context: { | ||
| repo: { owner: "getsentry", repo: "publish" }, | ||
| payload: { | ||
| sender: { login: "example-user" }, | ||
| issue: { number: "211" }, | ||
| }, | ||
| }, | ||
| octokit: { | ||
| rest: { | ||
| issues: { | ||
| createComment: vi.fn(), | ||
| update: vi.fn(), | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| await retractRelease(retractArgs); | ||
|
|
||
| const commentMock = retractArgs.octokit.rest.issues.createComment; | ||
| expect(commentMock).toHaveBeenCalledTimes(1); | ||
| expect(commentMock.mock.calls[0][0]).toEqual({ | ||
| body: `Release request retracted by @example-user. | ||
| You may also want to remove your [release branch](https://github.com/getsentry/sentry/branches/all?query=21.3.1).`, | ||
| issue_number: "211", | ||
| owner: "getsentry", | ||
| repo: "publish", | ||
| }); | ||
|
|
||
| const updateMock = retractArgs.octokit.rest.issues.update; | ||
| expect(updateMock).toHaveBeenCalledTimes(1); | ||
| expect(updateMock.mock.calls[0][0]).toEqual({ | ||
| issue_number: "211", | ||
| state: "closed", | ||
| owner: "getsentry", | ||
| repo: "publish", | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| async function retract({ context, octokit, inputs }) { | ||
| const { repo, version } = inputs; | ||
| const { repo: publishRepo } = context; | ||
| const { number: issue_number } = context.payload.issue; | ||
| const { login } = context.payload.sender; | ||
|
|
||
| await Promise.all([ | ||
| octokit.rest.issues.createComment({ | ||
| ...publishRepo, | ||
| issue_number, | ||
| body: `Release request retracted by @${login}.\nYou may also want to remove your [release branch](https://github.com/getsentry/${repo}/branches/all?query=${encodeURIComponent( | ||
| version | ||
| )}).`, | ||
| }), | ||
|
|
||
| octokit.rest.issues.update({ | ||
| ...publishRepo, | ||
| issue_number, | ||
| state: "closed", | ||
| }), | ||
| ]); | ||
| }; | ||
|
|
||
| module.exports = retract; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const github = require('@actions/github'); | ||
| const retract = require('../modules/retract-release'); | ||
| const {getGitHubToken} = require('../libs/github'); | ||
|
|
||
| const context = github.context; | ||
| const octokit = github.getOctokit(getGitHubToken()); | ||
| const inputs = JSON.parse(process.env.PUBLISH_ARGS); | ||
|
|
||
| retract({context, octokit, inputs}); |
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.
Missing
requesterfield makes retract always skipHigh Severity
The workflow condition checks
fromJSON(steps.inputs.outputs.result).requester, butdetailsFromContext(invoked byinputs.js) never includes arequesterfield in its return value — it only returnsrepo,path,version,dry_run,merge_target, andtargets. Sincerequesteris alwaysundefined, the comparison withgithub.event.sender.loginwill always be false, causing the "Comment and close" step to be permanently skipped. The#retractcommand will never actually work.