Skip to content

Commit f098db8

Browse files
committed
action.yml: add working-directory parameter
1 parent b45ffc1 commit f098db8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ jobs:
4747
[ "$(git config user.name)" = "Ansible Documentation Bot" ]
4848
[ "$(git config user.email)" = "${adb_email}" ]
4949
done
50+
git config --global --unset user.name
51+
git config --global --unset user.email
52+
53+
54+
- name: "3. Run complex case with working-directory"
55+
uses: ./
56+
with:
57+
working-directory: ./test
58+
- name: "3. Check complex case with working-directory"
59+
run: |
60+
cd test
61+
[ "$(git config user.name)" = "github-actions" ]
62+
[ "$(git config user.email)" = "${gha_email}" ]

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ inputs:
1313
description: "Name of the committer (user.name)"
1414
global:
1515
description: "Whether to set the config globally or only for the current repo"
16+
working-directory:
17+
description: "Directory in which to run commands"
18+
default: "."
1619
runs:
1720
using: composite
1821
steps:
@@ -22,6 +25,7 @@ runs:
2225
INPUT_BOT: "${{ inputs.bot }}"
2326
INPUT_NAME: "${{ inputs.name || inputs.bot }}"
2427
INPUT_GLOBAL: "${{ inputs.global }}"
28+
INPUT_WORKING_DIRECTORY: "${{ inputs.working-directory }}"
2529
SCRIPT: "${{ github.action_path }}/set_bot_user.sh"
2630
run: |
2731
set -euo pipefail
@@ -31,6 +35,7 @@ runs:
3135
if [[ "${INPUT_GLOBAL}" =~ (true|1) ]]; then
3236
args+=("--global")
3337
fi
38+
cd "${INPUT_WORKING_DIRECTORY}"
3439
set -x
3540
git config "${args[@]}" \
3641
user.name "${INPUT_NAME}"

0 commit comments

Comments
 (0)