PSMDB-1889 Restore sbom.json
#1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| pull_request: | |
| types: [opened, edited] | |
| concurrency: | |
| group: pr-comment-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| comment-policy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Post comment | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const targetBranch = context.payload.pull_request.base.ref; | |
| const prNumber = context.issue.number; | |
| const prAuthor = context.payload.pull_request.user.login; | |
| // Define regex patterns for production release and staging branches | |
| const productionBranchRegex = /^v[0-9]\.[0-9]$/; | |
| const stagingBranchRegex = /^v[0-9]\.[0-9]-staging$/; | |
| console.log(`PR target branch: ${targetBranch}`); | |
| // Define comments for each branch | |
| let commentBody = null; | |
| if (stagingBranchRegex.test(targetBranch)) { | |
| commentBody = | |
| "### [Backport Policy](https://wiki.corp.mongodb.com/x/nw5CCQ) Overview\n\n" + | |
| "@" + prAuthor + ", please ensure the following:\n\n" + | |
| "- A full Evergreen patch has been run, and the patch link has been posted in this PR. Any failures should be reviewed and explicitly confirmed as unrelated in the PR comments.\n" + | |
| "- The PR has been reviewed by a member of the [server-backport-mergers](https://github.com/orgs/10gen/teams/server-backport-mergers) team.\n" + | |
| "- For feature backports requiring a break-glass rebase: **Do not enable auto-merge**. Instead, post in [#10gen-mongo-break-glass-requests](https://mongodb.enterprise.slack.com/archives/C0877CMLRB4) for manual review.\n\n" + | |
| "The [server-backport-mergers](https://github.com/orgs/10gen/teams/server-backport-mergers) reviewer is responsible for enabling auto-merge after completing their review. Once auto-merge is enabled, @svc-auto-approve-bot will periodically evaluate merge readiness and approve the PR on behalf of Server Release when criteria is met.\n\n" + | |
| "---\n" + | |
| "Check Release Dates: [Server Release Schedule](https://jira.mongodb.org/secure/Dashboard.jspa?selectPageId=33483).\n" + | |
| "For questions, please reach out in [#server-release](https://mongodb.enterprise.slack.com/archives/C1XQ502TA)."; | |
| } else if (productionBranchRegex.test(targetBranch)) { | |
| const correspondingStagingBranch = `${targetBranch}-staging`; | |
| commentBody = | |
| "### [Backport Policy](https://wiki.corp.mongodb.com/x/nw5CCQ) Overview\n\n" + | |
| "@" + prAuthor + ", This branch (`" + targetBranch + "`) is a production release branch and does not accept direct PRs.\n" + | |
| "All changes must flow through the corresponding staging branch (`" + correspondingStagingBranch + "`), where they are tested and validated before being promoted into `" + targetBranch + "` by the Server Release team.\n\n" + | |
| "**Next step:** Please re-open this PR against `" + correspondingStagingBranch + "`.\n\n"+ | |
| "Please reach out in [#server-release](https://mongodb.enterprise.slack.com/archives/C1XQ502TA) if you have any questions."; | |
| } else { | |
| console.log(`Branch ${targetBranch} does not match the Server Release branch pattern. Skipping.`); | |
| return; | |
| } | |
| // Check if the comment for this branch already exists | |
| console.log("Checking for existing comments..."); | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| issue_number: prNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| }); | |
| const alreadyCommented = comments.some(comment => comment.body && comment.body.includes(commentBody)); | |
| if (alreadyCommented) { | |
| console.log("Comment already posted for this branch. Skipping."); | |
| return; | |
| } | |
| // Post the comment if it hasn't been posted yet | |
| await github.rest.issues.createComment({ | |
| issue_number: prNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: commentBody, | |
| }); | |
| console.log(`Comment posted: ${commentBody}`); |