[IGNORE] CI Test #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
| name: 'Create PR Checklist' | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| pull-requests: write | |
| statuses: write | |
| issues: write # needed to add labels | |
| contents: read # needed to get collaborators | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if PR author is a maintainer | |
| id: check_maintainer | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| // Fetch the PR author | |
| const prUser = context.payload.pull_request.user.login; | |
| console.log(`PR author: ${prUser}`); | |
| // Check if author is a collaborator (maintainer) | |
| try { | |
| const { status } = await github.rest.repos.checkCollaborator({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| username: prUser, | |
| }); | |
| console.log(`Collaborator check status: ${status}`); | |
| console.log(`${prUser} is a maintainer.`); | |
| core.setOutput("is_maintainer", true); | |
| } catch (error) { | |
| if (error.status === 404) { | |
| console.log(`${prUser} is NOT a maintainer.`); | |
| core.setOutput("is_maintainer", false); | |
| } else { | |
| console.log(`Error checking collaborator: ${error}`); | |
| throw error; | |
| } | |
| } | |
| - name: Add labels | |
| #if: steps.check_maintainer.outputs.is_maintainer == 'false' | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| labels: ['community'] | |
| }); | |
| - name: Create pending statuses | |
| #if: steps.check_maintainer.outputs.is_maintainer == 'false' | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const checklist = [ | |
| { key: "internal-ticket", context: "Create an internal ticket" }, | |
| { key: "view-testing", context: "Complete view testing" }, | |
| ]; | |
| for (const item of checklist) { | |
| await github.rest.repos.createCommitStatus({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| sha: context.payload.pull_request.head.sha, | |
| state: 'pending', | |
| context: item.context, | |
| description: 'Awaiting manual approval via checklist', | |
| }); | |
| } | |
| - name: Create PR checklist comment | |
| #if: steps.check_maintainer.outputs.is_maintainer == 'false' | |
| uses: wadackel/checkbox-workflow-action@v1 | |
| with: | |
| id: pr-checklist | |
| number: ${{ github.event.pull_request.number }} | |
| config: | | |
| [ | |
| {"internal-ticket": "Create an internal ticket"}, | |
| {"view-testing": "Complete view testing"} | |
| ] | |
| message: | | |
| ## PR Checklist | |
| {{body}} |