github.com/letsencrypt/boulder@v0.20251208.0/.github/workflows/issue-for-sre-handoff.yml (about)

     1  name: Check PR for configuration and SQL changes
     2  
     3  on:
     4    pull_request:
     5      types: [review_requested]
     6      paths:
     7      - 'test/config-next/*.json'
     8      - 'test/config-next/*.yaml'
     9      - 'test/config-next/*.yml'
    10      - 'sa/db-users/*.sql'
    11      - 'sa/db-next/**/*.sql'
    12      - 'sa/db/**/*.sql'
    13  
    14  jobs:
    15    check-changes:
    16      runs-on: ubuntu-latest
    17      permissions:
    18        pull-requests: write
    19      steps:
    20        - name: Comment PR
    21          uses: actions/github-script@v8
    22          with:
    23            script: |
    24              const commentMarker = '<!-- deployment_ticket_check -->';
    25              const prAuthor = context.payload.pull_request.user.login;
    26              const commentBody = `${commentMarker}\n@${prAuthor}, this PR appears to contain configuration and/or SQL schema changes. Please ensure that a corresponding deployment ticket has been filed with the new values.\n`;
    27              const { owner, repo, number: issue_number } = context.issue;
    28              const issueRegexp = /IN-\d+/;
    29  
    30              // Get PR body and all issue comments.
    31              const prBody = context.payload.pull_request.body;
    32              const comments = await github.rest.issues.listComments({
    33                owner,
    34                repo,
    35                issue_number
    36              });
    37  
    38              if (issueRegexp.test(prBody) || comments.data.some(c => issueRegexp.test(c.body))) {
    39                  // Issue number exists in PR body or comments.
    40                  return;
    41                }
    42  
    43              if (comments.data.find(c => c.body.includes(commentMarker))) {
    44                // Comment already exists.
    45                return;
    46              }
    47  
    48              // No issue number or comment were found, post the comment.
    49              await github.rest.issues.createComment({
    50                owner,
    51                repo,
    52                issue_number,
    53                body: commentBody
    54              });
    55            github-token: ${{ secrets.GITHUB_TOKEN }}