Skip to content

Commit

Permalink
GitHub Action: properly respect the working_directory argument (#3905)
Browse files Browse the repository at this point in the history
Signed-off-by: Pino Toscano <[email protected]>
  • Loading branch information
ptoscano authored Nov 27, 2023
1 parent 6e78ac3 commit 5fda814
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ inputs:
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
# 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
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
wget --output-document=.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt
Expand All @@ -36,7 +47,7 @@ runs:
uses: actions/setup-python@v4
with:
cache: pip
cache-dependency-path: .git/ansible-lint-requirements.txt
cache-dependency-path: ${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt
python-version: "3.11"

- name: Install ansible-lint
Expand All @@ -50,16 +61,6 @@ runs:
pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}"
ansible-lint --version
- 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: Run ansible-lint
shell: bash
working-directory: ${{ steps.inputs.outputs.working_directory }}
Expand Down

0 comments on commit 5fda814

Please sign in to comment.