From c8de132e711231e4d5f1ddd1c6f94811ada7b7f4 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 10 Oct 2024 16:48:13 +0800 Subject: [PATCH] fix: Explicitly use SYNC_TOKEN for GitHub authentication --- action.yml | 2 +- src/entrypoint.sh | 6 +++++- src/sync_template.sh | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a59b4643..034ac2b5 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ branding: inputs: sync_token: description: 'Token for the repo. Can be passed in using $\{{ secrets.SYNC_TOKEN }}' - required: true + required: false github_token: description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}' required: true diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 839632bb..0ac5d995 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -157,7 +157,11 @@ function git_init() { ssh-keyscan -t rsa "${source_repo_hostname}" >> "${HOME}"/.ssh/known_hosts else info "the source repository is located within GitHub." - gh auth setup-git --hostname "${source_repo_hostname}" + if [[ "${SYNC_TOKEN}" ]]; then + gh auth login --with-token <<< "${SYNC_TOKEN}" + else + gh auth setup-git --hostname "${source_repo_hostname}" + fi gh auth status --hostname "${source_repo_hostname}" fi echo "::endgroup::" diff --git a/src/sync_template.sh b/src/sync_template.sh index b1cf3005..55b22f25 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -300,7 +300,7 @@ function push () { function switch_to_github_token_auth() { info "Switching to GITHUB_TOKEN for authentication" gh auth logout - echo "$GITHUB_TOKEN" | gh auth login --with-token + gh auth login --with-token <<< "${GITHUB_TOKEN}" } ####################################