Currently I have this file to check for linting errors when a PR is created on GitHub, but it targets only a single branch i.e branch_name and I have to change the branch name for every branch, how can I configure this to run on the branch that the PR is currently targeting?
I have tried to use pattern matching by using ** as described here but that doesn't work.
name: Lint Code Base
on:
pull_request:
branches: [branch_name]
jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: branch_name
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISABLE_ERRORS: true
PYTHON_FLAKE8_CONFIG_FILE: .flake8
VALIDATE_PYTHON_FLAKE8: true
To trigger on any PR, and have super-linter run for the diff between the head branch and the base branch of the PR, you have to
pull_request
on any branches, andDEFAULT_BRANCH
environment variable to the base branch of the PR.Arguably,
DEFAULT_BRANCH
isn't a great name for that variable, because it's used to build the list of changed files, and PRs can be opened into branches other than the default branch of a repository.Additionally:
fetch-depth: 0
is necessary, but the super-linter README recommends it anywayTaken all together: