Skip to content

Commit

Permalink
Allow users to specify custom tokens (#5)
Browse files Browse the repository at this point in the history
* chore(actions): allow user specified tokens

* feat: set token for `git` too

* feat: use bash substitution instead of plaintext token storage

* fix: invalid bash substitution syntax

* fix: actually do the substitution lol

* chore: semicolons for style
  • Loading branch information
CompeyDev authored Oct 21, 2024
1 parent 0c97174 commit 696d229
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
description: Do the force push in this action
required: false
default: true
token:
description: GitHub token to access to API and git
required: false
default: ${{ github.token }}

runs:
using: composite
Expand All @@ -29,8 +33,9 @@ runs:
set -ex;
UPSTREAM=${{ inputs.upstream }};
GITHUB_TOKEN=${{ inputs.token }};
if [ -z $UPSTREAM ]; then
echo ${{ github.token }} | gh auth login --with-token;
echo GITHUB_TOKEN | gh auth login --with-token;
UPSTREAM=$(gh api repos/:owner/:repo --jq .parent.full_name);
if [ -z $UPSTREAM ]; then echo "Can't find upstream" >&2 && exit 1; fi;
fi;
Expand All @@ -51,6 +56,7 @@ runs:
git rebase upstream/${{ inputs.branch }};
if [ "${{ inputs.push }}" = "true" -a "$(git status | grep diverged)" ]; then
git push origin $(git branch --show-current) --force-with-lease;
ORIGIN_URL=$(git remote get-url origin);
git push "${ORIGIN_URL/https:\/\//https:\/\/$GITHUB_TOKEN@}" $(git branch --show-current) --force-with-lease;
fi;
shell: bash

0 comments on commit 696d229

Please sign in to comment.