ansible-lint/action.yml

63 lines
1.9 KiB
YAML
Raw Permalink Normal View History

2024-09-27 07:46:53 +02:00
---
# Original Author: Ansible by Red Hat <info@ansible.com> (https://github.com/ansible/ansible-lint)
name: run-ansible-lint
description: Run Ansible Lint
author: Michael Sasser <info@michaelsasser.org>
2024-11-19 03:39:52 +01:00
2024-09-27 07:46:53 +02:00
branding:
icon: shield
2024-11-19 03:39:52 +01:00
color: blue
2024-09-27 07:46:53 +02:00
inputs:
args:
description: Arguments to be passed to ansible-lint command.
required: false
default: ""
working_directory:
description: The directory where to run ansible-lint from. Default is `github.workspace`.
required: false
default: ""
requirements_file:
description: Path to the requirements YAML file to install role and collection dependencies.
required: false
default: ""
expected_return_code:
description: Expected return code from ansible-lint. Default is 0. Used for self-testing purposes.
required: false
default: "0"
2024-11-19 03:39:52 +01:00
2024-09-27 07:46:53 +02:00
runs:
using: composite
steps:
- name: Process inputs
id: inputs
shell: bash
run: |
if [[ -n "${{ inputs.working_directory }}" ]]; then
echo "working_directory=${{ inputs.working_directory }}" >> $GITHUB_OUTPUT
else
echo "working_directory=${{ github.workspace }}" >> $GITHUB_OUTPUT
fi
- name: Install role and collection dependencies from requirements file
if: inputs.requirements_file != ''
shell: bash
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: ansible-galaxy install -r ${{ inputs.requirements_file }}
- name: Run ansible-lint
shell: bash
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
exit_code=0
expected_exit_code=${{ inputs.expected_return_code }}
2024-11-19 03:39:52 +01:00
ansible-lint --version
2024-09-27 07:46:53 +02:00
ansible-lint ${{ inputs.args }} || exit_code=$?
2024-11-19 03:39:52 +01:00
if [ "$exit_code" != "$expected_exit_code" ]; then
echo "Command failed: got '$exit_code', expected '$expected_exit_code'"
exit 1
fi