Skip to content

Ensure PR workflows can run on all PRs (but still skip when they're not needed) #303

Ensure PR workflows can run on all PRs (but still skip when they're not needed)

Ensure PR workflows can run on all PRs (but still skip when they're not needed) #303

Workflow file for this run

name: ansible-lint
on: [push, pull_request]
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
# In order to be able to have required checks, a workflow can't be entirely
# skipped: see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
paths-filter:
name: "Filter Paths"
runs-on: ubuntu-latest
outputs:
matches: ${{ steps.filter.outputs.matches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # important, to fetch previous commit
# workaround for https://github.com/dorny/paths-filter/issues/240
- id: previous-sha
run: 'echo "sha=$(git rev-list -n 1 ${{ github.ref }}^)" >> $GITHUB_OUTPUT'
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
- uses: dorny/paths-filter@v3
id: filter
with:
base: "${{ steps.previous-sha.outputs.sha }}"
filters: |
matches:
- 'ansible/**'
- '.github/workflows/ansible-lint.yaml'
debug:
needs: paths-filter
runs-on: ubuntu-latest
steps:
- name: echo
run: echo "${{steps.filter.outputs.matches}}"
build:
needs: paths-filter
if: needs.paths-filter.outputs.matches == 'true'
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # needed for progressive mode to work
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
cd ansible/
python -m pip install --upgrade pip
pip install pipenv
pipenv sync
- name: Lint
run: |
cd ansible
pipenv run ansible-lint -c ./lint-cfg.yml ./do_setup.yml