[IGNORE] CI Test #4
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 | ||
| members: read # needed to check team membership | ||
| jobs: | ||
| setup: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check if PR author is a team member | ||
| id: check_team_member | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const prUser = context.payload.pull_request.user.login; | ||
| console.log(`PR author: ${prUser}`); | ||
| // List of team slugs to check (update these with your actual team names) | ||
| const teamSlugs = ['rvos-committers']; | ||
| let isTeamMember = false; | ||
| // Check if author is a member of any of the specified teams | ||
| for (const teamSlug of teamSlugs) { | ||
| try { | ||
| await github.rest.teams.getMembershipForUserInOrg({ | ||
| org: context.repo.owner, | ||
| team_slug: teamSlug, | ||
| username: prUser, | ||
| }); | ||
| console.log(`${prUser} is a member of team: ${teamSlug}`); | ||
| isTeamMember = true; | ||
| break; | ||
| } catch (error) { | ||
| if (error.status === 404) { | ||
| console.log(`${prUser} is NOT a member of team: ${teamSlug}`); | ||
| } else { | ||
| console.log(`Error checking team membership for ${teamSlug}: ${error.message}`); | ||
| } | ||
| } | ||
| } | ||
| core.setOutput("is_team_member", isTeamMember); | ||
| console.log(`Final result - is_team_member: ${isTeamMember}`); | ||
| - name: Add community label | ||
| if: steps.check_team_member.outputs.is_team_member == '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 for community PRs | ||
| if: steps.check_team_member.outputs.is_team_member == '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: Auto-approve statuses for team member PRs | ||
| if: steps.check_team_member.outputs.is_team_member == 'true' | ||
| 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: 'success', | ||
| context: item.context, | ||
| description: 'Auto-approved for team member', | ||
| }); | ||
| } | ||
| - name: Create PR checklist comment for community PRs | ||
| if: steps.check_team_member.outputs.is_team_member == '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}} | ||