fix: auto approve internal commits #6
Workflow file for this run
This file contains 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: E2E Tests | |
on: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- '**' | |
jobs: | |
get-team-members: | |
runs-on: ubuntu-latest | |
outputs: | |
team-members: ${{ steps.get-team-members.outputs.team-members }} | |
steps: | |
- name: Get team members | |
id: get-team-members | |
run: | | |
TEAM_MEMBERS="nachoaldamav" | |
echo "team-members=$TEAM_MEMBERS" >> $GITHUB_OUTPUT | |
check-author: | |
runs-on: ubuntu-latest | |
needs: get-team-members | |
outputs: | |
is-external: ${{ steps.check-author.outputs.is-external }} | |
steps: | |
- name: Check if PR is from a team member | |
id: check-author | |
run: | | |
TEAM_MEMBERS="${{ needs.get-team-members.outputs.team-members }}" | |
if [ "${{ github.event.pull_request }}" != "" ]; then | |
if echo "$TEAM_MEMBERS" | grep -q "${{ github.actor }}"; then | |
echo "PR is from a team member." | |
echo "is-external=false" >> $GITHUB_OUTPUT | |
else | |
echo "PR is from an external contributor." | |
echo "is-external=true" >> $GITHUB_OUTPUT | |
fi | |
else | |
echo "Not a PR, running the workflow." | |
echo "is-external=false" >> $GITHUB_OUTPUT | |
fi | |
require-approval: | |
runs-on: ubuntu-latest | |
needs: check-author | |
steps: | |
- name: Manual Approval | |
uses: actions/github-script@v6 | |
if: ${{ needs.check-author.outputs.is-external == 'true' }} | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const repo = context.repo; | |
github.rest.pulls.requestReviewers({ | |
owner: repo.owner, | |
repo: repo.repo, | |
pull_number: prNumber, | |
reviewers: ['nachoaldamav'] | |
}); | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Auto Approve | |
uses: actions/github-script@v6 | |
if: ${{ needs.check-author.outputs.is-external == 'false' }} | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const repo = context.repo; | |
github.rest.pulls.createReview({ | |
owner: repo.owner, | |
repo: repo.repo, | |
pull_number: prNumber, | |
event: 'APPROVE' | |
}); | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
windows-tests: | |
needs: [require-approval, get-team-members] | |
uses: ./.github/workflows/windows.yml | |
macos-tests: | |
needs: [require-approval, get-team-members] | |
uses: ./.github/workflows/macos.yml | |
linux-tests: | |
needs: [require-approval, get-team-members] | |
uses: ./.github/workflows/linux.yml |