diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b63baf8..6f306da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,14 +103,14 @@ jobs: uses: ./ with: depth: '' - checkout_dir: step.authoer + checkout_dir: step.author - name: Have user.name and user.email on .git/config? run: | set -xe pwd ls -al - pushd step.authoer + pushd step.author if [ "${GITHUB_ACTOR}" != "$(git config --local --get user.name)" ]; then echo '::error:: "git config --local --get user.name" Should be equal' "$GITHUB_ACTOR" exit 1 @@ -154,6 +154,32 @@ jobs: exit 1 fi + - name: Test Write checkout dir to safe.dirctory on .gitconfig + uses: ./ + with: + depth: '' + checkout_dir: step.checkout-dir + + - name: Have a current directory in safe.directory on .gitconfig + run: | + set -xe + pwd + SAFE_DIRECTORIES=$(git config --get-all safe.directory) + EXPECT="$(pwd)/step.checkout-dir" + + FOUND=false + for s in $SAFE_DIRECTORIES; do + if [ "$s" = "$EXPECT" ]; then + FOUND=true + fi + done + + if [ "$FOUND" = 'false' ]; then + echo "::error:: safe.directory内に $EXPECT が見つかりません" + echo "$SAFE_DIRECTORIES" + exit 1 + fi + - name: Setup github.com connection continue-on-error: true run: | diff --git a/action.yml b/action.yml index b2ad9fe..ee395dd 100644 --- a/action.yml +++ b/action.yml @@ -27,7 +27,7 @@ inputs: default: false checkout_dir: description: 'Name of directory to check out' - required: true + default: '.' depth: description: 'git clone --depth={} option' default: '' @@ -80,7 +80,7 @@ runs: https://${{ inputs.github_actor }}:${{ inputs.github_token }}@github.com/${{ inputs.github_repository }}.git \ ${{ inputs.checkout_dir }} - CHECKOUT_FULL_PATH="$(pwd)${{ inputs.checkout_dir }})" + CHECKOUT_FULL_PATH="$(pwd)/${{ inputs.checkout_dir }}" CHECKOUT_FULL_PATH="$(realpath $CHECKOUT_FULL_PATH)" if [ $(git config --global --get-all safe.directory | grep -c "${CHECKOUT_FULL_PATH}$") -eq 0 ]; then /usr/bin/git config --global --add safe.directory "${CHECKOUT_FULL_PATH}"