Skip to content

Commit 55b8b66

Browse files
Do not use github action path for running ansible lint (#3798)
Co-authored-by: Sorin Sbarnea <[email protected]>
1 parent ca69220 commit 55b8b66

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
name: Ansible Lint # Naming the build is important to use it as a status check
2929
runs-on: ubuntu-latest
3030
steps:
31+
- uses: actions/checkout@v4
3132
- name: Run ansible-lint
3233
uses: ansible/ansible-lint@main # or version tag instead of 'main'
3334
```

action.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ branding:
77
color: red
88
inputs:
99
args:
10-
description: Arguments to be passed to ansible-lint command
10+
description: Arguments to be passed to ansible-lint command.
11+
required: false
12+
default: ""
13+
setup_python:
14+
description: If false, this action will not setup python and will instead rely on the already installed python.
15+
required: false
16+
default: true
17+
working_directory:
18+
description: The directory where to run ansible-lint from. Default is `github.workspace`.
1119
required: false
1220
default: ""
1321
runs:
1422
using: composite
1523
steps:
16-
- uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0 # needed by setuptools-scm
19-
submodules: true
20-
2124
# Due to GHA limitation, caching works only for files within GITHUB_WORKSPACE
2225
# folder, so we are forced to stick this temporary file inside .git, so it
2326
# will not affect the linted repository.
@@ -29,6 +32,7 @@ runs:
2932
wget --output-file=.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt
3033
3134
- name: Set up Python
35+
if: inputs.setup_python == 'true'
3236
uses: actions/setup-python@v4
3337
with:
3438
cache: pip
@@ -46,6 +50,17 @@ runs:
4650
pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}"
4751
ansible-lint --version
4852
53+
- name: Process inputs
54+
id: inputs
55+
shell: bash
56+
run: |
57+
if [[ -n "${{ inputs.working_directory }}" ]]; then
58+
echo "working_directory=${{ inputs.working_directory }}" >> $GITHUB_OUTPUT
59+
else
60+
echo "working_directory=${{ github.workspace }}" >> $GITHUB_OUTPUT
61+
fi
62+
4963
- name: Run ansible-lint
5064
shell: bash
65+
working-directory: ${{ steps.inputs.outputs.working_directory }}
5166
run: ansible-lint ${{ inputs.args }}

0 commit comments

Comments
 (0)