ansible-lint-role/action.yml

45 lines
1.4 KiB
YAML
Raw Normal View History

2024-11-19 03:35:36 +01:00
---
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:
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
2024-11-19 04:21:55 +01:00
id: get-role-dependencies
2024-11-19 03:35:36 +01:00
run: |
2024-11-19 04:21:55 +01:00
if test -f "${{ github.workspace }}/meta/requirements.yml"; then
echo "The role has dependencies"
echo '::set-output name=has_dependencies::true'
2024-11-19 03:35:36 +01:00
else
2024-11-19 04:21:55 +01:00
echo "The role does not have dependencies"
echo '::set-output name=has_dependencies::false'
2024-11-19 03:35:36 +01:00
fi
# Run linter
- name: Run ansible-lint (with dependencies)
2024-11-19 04:21:55 +01:00
if: ${{ steps.get-role-dependencies.outputs.has_dependencies == 'true' }}
2024-11-19 03:35:36 +01:00
uses: https://git.michaelsasser.org/actions/ansible-lint@main
with:
args: ${{ inputs.args }}
2024-11-19 04:21:55 +01:00
requirements_file: ${{ github.workspace }}/meta/requirements.yml
2024-11-19 03:35:36 +01:00
- name: Run ansible-lint (without dependencies) # same but without: requirements_file
2024-11-19 04:21:55 +01:00
if: ${{ steps.get-role-dependencies.outputs.has_dependencies == 'false' }}
2024-11-19 03:35:36 +01:00
uses: https://git.michaelsasser.org/actions/ansible-lint@main
with:
args: ${{ inputs.args }}