summaryrefslogtreecommitdiffstats
path: root/action.yml
blob: 4c541bf53ba8a24f9f390b6fef5494c35933387d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
name: run-ansible-lint
description: Run Ansible Lint
author: Ansible by Red Hat <info@ansible.com>
branding:
  icon: shield
  color: red
inputs:
  args:
    description: Arguments to be passed to ansible-lint command
    required: false
    default: ""
runs:
  using: composite
  steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0 # needed by setuptools-scm
        submodules: true

    - name: Generate ansible-lint-requirements.txt
      shell: bash
      run: |
        wget --output-file=$HOME/requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        cache: pip
        cache-dependency-path: ~/requirements.txt
        python-version: "3.11"

    - name: Install ansible-lint
      shell: bash
      # We need to set the version manually because $GITHUB_ACTION_PATH is not
      # a git clone and setuptools-scm would not be able to determine the version.
      # git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}
      # SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.action_ref || 'main' }}
      run: |
        cd $GITHUB_ACTION_PATH
        pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}"
        ansible-lint --version

    - name: Run ansible-lint
      shell: bash
      run: ansible-lint ${{ inputs.args }}