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

Add authentication check #146

Merged
merged 1 commit into from
Nov 2, 2022
Merged

Conversation

MrChrisW
Copy link
Contributor

@MrChrisW MrChrisW commented Nov 2, 2022

This adds an authentication check before attempting to create a pull request via the action. If the check fails we do not proceed to create a pull request. It provides a useful error message when reviewing the action logs.

When running this action I noticed the following error when a GITHUB_TOKEN expires:

jq: error (at <stdin>:4): Cannot index string with string "head"

This is caused by an attempt to get the head ref when the API responds with an error:

{ "message": "Bad credentials", "documentation_url": "https://docs.github.com/rest" }

PULL_REQUESTS=$(echo "$(curl -sSL -H "${AUTH_HEADER}" -H "${HEADER}" -X GET "${PULLS_URL}${PULL_REQUESTS_QUERY_PARAMS}")" | jq --raw-output '.[] | .head.ref ')

Check the token can authenticate against
the GitHub API before proceeding to create
a pull request
@andrii-bodnar
Copy link
Member

@MrChrisW thanks a lot for your contribution! 🚀

@andrii-bodnar andrii-bodnar merged commit 70f3b47 into crowdin:master Nov 2, 2022
@MrChrisW MrChrisW deleted the token-auth branch November 2, 2022 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants