summaryrefslogtreecommitdiffstats
path: root/action.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:58 +0000
commitba233a0cbad76b4783a03893e7bf4716fbc0f0ec (patch)
treead369728c1edbe3631c8150585659078ae5d7d0b /action.yml
parentReleasing progress-linux version 6.17.2-3~progress7.99u1. (diff)
downloadansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.tar.xz
ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.zip
Merging upstream version 24.6.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'action.yml')
-rw-r--r--action.yml45
1 files changed, 35 insertions, 10 deletions
diff --git a/action.yml b/action.yml
index 4c541bf..692a9b3 100644
--- a/action.yml
+++ b/action.yml
@@ -7,40 +7,65 @@ branding:
color: red
inputs:
args:
- description: Arguments to be passed to ansible-lint command
+ description: Arguments to be passed to ansible-lint command.
+ required: false
+ default: ""
+ setup_python:
+ description: If false, this action will not setup python and will instead rely on the already installed python.
+ required: false
+ default: true
+ working_directory:
+ description: The directory where to run ansible-lint from. Default is `github.workspace`.
required: false
default: ""
runs:
using: composite
steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0 # needed by setuptools-scm
- submodules: true
+ - 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: Generate ansible-lint-requirements.txt
+ # Due to GHA limitation, caching works only for files within GITHUB_WORKSPACE
+ # folder, so we are forced to stick this temporary file inside .git, so it
+ # will not affect the linted repository.
+ # https://github.com/actions/toolkit/issues/1035
+ # https://github.com/actions/setup-python/issues/361
+ - name: Generate .git/ansible-lint-requirements.txt
shell: bash
+ env:
+ GH_ACTION_REF: ${{ github.action_ref || 'main' }}
+ working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
- wget --output-file=$HOME/requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt
+ wget --output-document=${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
- name: Set up Python
- uses: actions/setup-python@v4
+ if: inputs.setup_python == 'true'
+ uses: actions/setup-python@v5
with:
cache: pip
- cache-dependency-path: ~/requirements.txt
+ cache-dependency-path: ${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt
python-version: "3.11"
- name: Install ansible-lint
shell: bash
+ env:
+ GH_ACTION_REF: ${{ github.action_ref || 'main' }}
# 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' }}"
+ pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@$GH_ACTION_REF"
ansible-lint --version
- name: Run ansible-lint
shell: bash
+ working-directory: ${{ steps.inputs.outputs.working_directory }}
run: ansible-lint ${{ inputs.args }}