name: Check PR for configuration changes on: pull_request: types: [opened, synchronize, reopened] paths: - 'features/featureflag_string.go' - 'test/config-next/*.json' - 'test/config-next/*.yaml' - 'test/config-next/*.yml' jobs: check-changes: runs-on: ubuntu-latest steps: - name: Comment PR uses: actions/github-script@v6 with: script: | const commentMarker = ''; const prAuthor = context.payload.pull_request.user.login; const commentBody = `${commentMarker}\n@${prAuthor}, this PR appears to contain configuration changes. Please ensure that a corresponding deployment ticket has been filed with the new configuration values.\n`; const { owner, repo, number: issue_number } = context.issue; const issueRegexp = /IN-\d+/; // Get PR body and all issue comments. const prBody = context.payload.pull_request.body; const comments = await github.rest.issues.listComments({ owner, repo, issue_number }); if (issueRegexp.test(prBody) || comments.data.some(c => issueRegexp.test(c.body))) { // Issue number exists in PR body or comments. return; } if (comments.data.find(c => c.body.includes(commentMarker))) { // Comment already exists. return; } // No issue number or comment were found, post the comment. await github.rest.issues.createComment({ owner, repo, issue_number, body: commentBody }); github-token: ${{ secrets.GITHUB_TOKEN }}