Skip to content

Commit

Permalink
fix: Explicitly use SYNC_TOKEN for GitHub authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
xesrevinu committed Oct 10, 2024
1 parent 424f1b6 commit 5d5f0c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +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."
if [[ "${SYNC_TOKEN}" ]]; then
# clear GITHUB_TOKEN
unset GITHUB_TOKEN
gh auth login --with-token <<< "${SYNC_TOKEN}"
fi
gh auth setup-git --hostname "${source_repo_hostname}"
gh auth status --hostname "${source_repo_hostname}"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

####################################
Expand Down

0 comments on commit 5d5f0c4

Please sign in to comment.