Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GitHub auth method #41

Merged
merged 9 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
cat <<EOS | jq > expected.json
{
"author": {
"login": "github-actions"
"is_bot": true,
"login": "app/github-actions"
},
"body": "",
"files": [
Expand Down
9 changes: 5 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ esac
git config --global user.name ${INPUT_GIT_USER}
git config --global user.email ${INPUT_GIT_EMAIL}

# Set GITHUB_USER to workaround hub command auth error
# https://github.com/github/hub/issues/2149#issuecomment-513214342
export GITHUB_USER="${GITHUB_ACTOR}"
export GITHUB_TOKEN=${INPUT_GITHUB_TOKEN}
git config --global \
url."https://x-access-token:${INPUT_GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

for repo in ${INPUT_REPOS}
do
echo "Syncing ${repo}"
tmpdir=$(mktemp -d)
git clone --depth=1 https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${repo} ${tmpdir}
git clone --depth=1 https://github.com/${repo} ${tmpdir}
base_branch=$(git -C ${tmpdir} symbolic-ref --short HEAD)
git -C ${tmpdir} checkout -b ${head_branch}

Expand Down Expand Up @@ -102,6 +101,7 @@ do
message=${message_template//%v/${version}}
git -C ${tmpdir} commit -m "${message}"

echo "Pushing branch"
if ! ${push_prefix} git -C ${tmpdir} push ${force_push} origin ${head_branch}
then
# Allow to fetch existing PR branch
Expand All @@ -120,6 +120,7 @@ do
echo "- Reusing existing branch"
fi

echo "Opening PR"
if [ $(cd ${tmpdir}; gh pr list --head ${head_branch} | wc -l) -gt 0 ]
then
echo "- PR is already open"
Expand Down