49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
|
---
|
||
|
name: run-ansible-lint-role
|
||
|
description: Run Ansible Lint on a role using our defaults.
|
||
|
author: Michael Sasser <info@michaelsasser.org>
|
||
|
|
||
|
branding:
|
||
|
icon: shield
|
||
|
color: blue
|
||
|
|
||
|
inputs:
|
||
|
requirements_file:
|
||
|
description: Path to the requirements file.
|
||
|
required: false
|
||
|
default: "${{ github.workspace }}/meta/requirements.yml"
|
||
|
args:
|
||
|
description: Arguments to be passed to ansible-lint command. Defaults to '--show-relpath'
|
||
|
required: false
|
||
|
default: "--show-relpath"
|
||
|
|
||
|
runs:
|
||
|
using: composite
|
||
|
steps:
|
||
|
# Check if dependencies exist.
|
||
|
- name: Check if the role has dependencies
|
||
|
shell: bash
|
||
|
id: get-role-has-dependencies
|
||
|
run: |
|
||
|
if test -f "${{ inputs.requirements_file }}"; then
|
||
|
echo 'The requirements file ${{ inputs.requirements_file }} exists'
|
||
|
echo '::set-output name=role_has_dependencies::true'
|
||
|
else
|
||
|
echo 'The requirements file ${{ inputs.requirements_file }} does not exist'
|
||
|
echo '::set-output name=role_has_dependencies::false'
|
||
|
fi
|
||
|
|
||
|
# Run linter
|
||
|
- name: Run ansible-lint (with dependencies)
|
||
|
if: ${{ steps.get-role-has-dependencies.outputs.role_has_dependencies == 'true' }}
|
||
|
uses: https://git.michaelsasser.org/actions/ansible-lint@main
|
||
|
with:
|
||
|
args: ${{ inputs.args }}
|
||
|
requirements_file: "${{ inputs.requirements_file }}"
|
||
|
|
||
|
- name: Run ansible-lint (without dependencies) # same but without: requirements_file
|
||
|
if: ${{ steps.get-role-has-dependencies.outputs.role_has_dependencies == 'false' }}
|
||
|
uses: https://git.michaelsasser.org/actions/ansible-lint@main
|
||
|
with:
|
||
|
args: ${{ inputs.args }}
|