Skip to content

Commit

Permalink
Add authentication check
Browse files Browse the repository at this point in the history
Check the token can authenticate against
the GitHub API before proceeding to create
a pull request
  • Loading branch information
MrChrisW committed Nov 1, 2022
1 parent 85c30ed commit ec22a49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ create_pull_request() {

PULLS_URL="${REPO_URL}/pulls"

auth_status=$(curl -sL --write-out '%{http_code}' --output /dev/null -H "${AUTH_HEADER}" -H "${HEADER}" "${PULLS_URL}")
if [[ $auth_status -eq 403 || "$auth_status" -eq 401 ]] ; then
echo "FAILED TO AUTHENTICATE USING 'GITHUB_TOKEN' CHECK TOKEN IS VALID"
exit 1
fi

echo "CHECK IF ISSET SAME PULL REQUEST"

if [ -n "$INPUT_PULL_REQUEST_BASE_BRANCH_NAME" ]; then
Expand Down

0 comments on commit ec22a49

Please sign in to comment.