Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 5a5d16b

Browse files
authored
Merge pull request #28 from aiming/fix-cannot-lfs-pull-when-invalid-actor-name
`inputs.github_acotor` の値により `lfs pull` できなくなる現象の修正
2 parents bb30903 + 3efdbda commit 5a5d16b

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ jobs:
180180
exit 1
181181
fi
182182
183+
- name: Test invalid github_actor value
184+
uses: ./
185+
with:
186+
github_actor: 'github-actions%5Bbot%5D'
187+
depth: ''
188+
checkout_dir: step.actor_includes_invalid_character
189+
190+
- name: Have Endpoint= line on `git lfs env` outputs
191+
run: |
192+
pushd step.actor_includes_invalid_character
193+
if [ $(git lfs env | grep 'Endpoint=' | grep 'info/lfs' | wc -l) == '1' ]; then
194+
# Found a line
195+
# Endpoint=github.com/org/repo.git/info/lfs
196+
exit 0
197+
else
198+
echo "::error:: git lfs envの値に `Endpoint=...info/lfs` の行が見つかりません"
199+
exit 1
200+
fi
201+
popd
202+
183203
- name: Setup github.com connection
184204
continue-on-error: true
185205
run: |

action.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ inputs:
3737
runs:
3838
using: "composite"
3939
steps:
40+
- uses: actions/github-script@v7
41+
id: script
42+
with:
43+
result-encoding: string
44+
script: |
45+
const actor = encodeURI('${{ inputs.github_actor }}')
46+
const token = encodeURI('${{ inputs.github_token }}')
47+
core.setOutput('actor', actor)
48+
core.setOutput('token', token)
49+
4050
- shell: bash
4151
if: ${{ !env.ACT }}
4252
run: |
@@ -50,14 +60,17 @@ runs:
5060
5161
try_till_success curl -s 'https://github.com' > /dev/null
5262
63+
GITHUB_ACTOR='${{ steps.script.outputs.actor }}'
64+
GITHUB_TOKEN='${{ steps.script.outputs.token }}'
65+
5366
export __SHA=${{ inputs.sha || github.sha }}
5467
if [ ! -z "${{ inputs.branch_name }}" ]; then
5568
# Remove "refs/heads/" at head if exists it
5669
__BRANCH=${{ inputs.branch_name }}
5770
__BRANCH=${__BRANCH#refs/heads/}
5871
5972
# Override sha value if branch_name is presented.
60-
__SHA=$(try_till_success /usr/bin/git ls-remote https://${{ inputs.github_actor }}:${{ inputs.github_token }}@github.com/${{ inputs.github_repository }}.git | grep -E "\srefs/heads/${__BRANCH}$" | cut -f 1 )
73+
__SHA=$(try_till_success /usr/bin/git ls-remote https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${{ inputs.github_repository }}.git | grep -E "\srefs/heads/${__BRANCH}$" | cut -f 1 )
6174
fi
6275
6376
if ! ${{ inputs.fetch_lfs }}; then
@@ -77,7 +90,7 @@ runs:
7790
/usr/bin/git clone \
7891
$DEPTH \
7992
$REFERENCE_IF_ABLE \
80-
https://${{ inputs.github_actor }}:${{ inputs.github_token }}@github.com/${{ inputs.github_repository }}.git \
93+
https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${{ inputs.github_repository }}.git \
8194
${{ inputs.checkout_dir }}
8295
8396
CHECKOUT_FULL_PATH="$(pwd)/${{ inputs.checkout_dir }}"
@@ -98,8 +111,6 @@ runs:
98111
99112
/usr/bin/git config --local user.name "${GITHUB_ACTOR}"
100113
/usr/bin/git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"
101-
# workaround `git lfs pull` is failure
102-
/usr/bin/git config lfs.url https://${{ inputs.github_actor }}:${{ inputs.github_token }}@github.com/${{ inputs.github_repository }}.git/info/lfs
103114
popd
104115
105116
unset GIT_LFS_SKIP_SMUDGE

0 commit comments

Comments
 (0)