diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da55d2d..86c0727 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,3 +47,16 @@ jobs: [ "$(git config user.name)" = "Ansible Documentation Bot" ] [ "$(git config user.email)" = "${adb_email}" ] done + git config --global --unset user.name + git config --global --unset user.email + + + - name: "3. Run complex case with working-directory" + uses: ./ + with: + working-directory: ./test + - name: "3. Check complex case with working-directory" + run: | + cd test + [ "$(git config user.name)" = "github-actions" ] + [ "$(git config user.email)" = "${gha_email}" ] diff --git a/action.yml b/action.yml index 28959c0..a5f0c60 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,9 @@ inputs: description: "Name of the committer (user.name)" global: description: "Whether to set the config globally or only for the current repo" + working-directory: + description: "Directory in which to run commands" + default: "." runs: using: composite steps: @@ -22,6 +25,7 @@ runs: INPUT_BOT: "${{ inputs.bot }}" INPUT_NAME: "${{ inputs.name || inputs.bot }}" INPUT_GLOBAL: "${{ inputs.global }}" + INPUT_WORKING_DIRECTORY: "${{ inputs.working-directory }}" SCRIPT: "${{ github.action_path }}/set_bot_user.sh" run: | set -euo pipefail @@ -31,6 +35,7 @@ runs: if [[ "${INPUT_GLOBAL}" =~ (true|1) ]]; then args+=("--global") fi + cd "${INPUT_WORKING_DIRECTORY}" set -x git config "${args[@]}" \ user.name "${INPUT_NAME}"