From 5fda8144e8b856bad82cf8064ab1c6446a27e303 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 27 Nov 2023 14:18:23 +0100 Subject: [PATCH] GitHub Action: properly respect the `working_directory` argument (#3905) Signed-off-by: Pino Toscano --- action.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 9d9b27370b..b2757df0e1 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,16 @@ 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. @@ -28,6 +38,7 @@ runs: # 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 @@ -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 @@ -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 }}