Skip to content

Workflow file for this run

name: Branch Protection
# This workflow is triggered on PRs to master branch on the repository
# It fails when someone tries to make a PR against the `main` branch instead of `dev`
on:
pull_request_target:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check PRs
if: github.repository == 'phac-nml/profile_dists'
run: |
{ [[ ${{github.event.pull_request.head.repo.full_name }} == phac-nml/profile_dists ]] && [[ $GITHUB_HEAD_REF == "dev" ]]; } || [[ $GITHUB_HEAD_REF == "patch" ]]
# If the above check failed, post a comment on the PR explaining the failure
# NOTE - this doesn't currently work if the PR is coming from a fork, due to limitations in GitHub actions secrets
- name: Post PR comment
if: failure()
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2
with:
message: |
## This PR is against the `main` branch :x:
* Do not close this PR
* Click _Edit_ and change the `base` to `dev`
* This CI test will remain failed until you push a new commit
---
Hello @${{ github.event.pull_request.user.login }}, This pull request is being made against the main branch, Please change your PR to be to the dev branch.
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false