Skip to content

Commit

Permalink
action.yml: add working-directory parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
gotmax23 committed Dec 6, 2023
1 parent b45ffc1 commit f098db8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" ]
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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}"
Expand Down

0 comments on commit f098db8

Please sign in to comment.