Skip to content

Add action to enforce PR policy #1

Add action to enforce PR policy

Add action to enforce PR policy #1

name: "Enforce PR policy"
on:
pull_request:
types:
- opened
- edited
- synchronize
jobs:
check_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check PR
run: |
PR_BASE=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json base -q ".base.ref")

Check failure on line 17 in .github/workflows/enforce-pr-policy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/enforce-pr-policy.yml

Invalid workflow file

You have an error in your yaml syntax on line 17
PR_HEAD=$(gh pr.view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json.head -q ".head.ref")
if [[ "$PR_BASE" == "main" ]] && ! [[ "$PR_HEAD" =~ ^dev$|^fix/ ]]; then
echo 'PRs to branch `main` can only come from branch `dev` or any branch prefixed with `fix/`'
exit 1
fi