-
Notifications
You must be signed in to change notification settings - Fork 0
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
How to use gh auth login CLI Programmatically in GitHub Actions | josh-ops #13
Comments
Thanks for sharing useful tips! 🙂 I was searching the same issue and found another way to set the token. ---
on:
- pull_request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
... This might be helpful in some case. |
ahh! That is super helpful, thanks for the tip @shuuji3 ! Then you can just run your regular |
I just updated the post to reflect this :) Thanks! |
Nice! Thank you for the update. |
Hey Josh, thanks for this! I was running into an issue using this auth method and was wondering if you could help! I wanted to use the command
With this, I still run into a HTTP 404 error on the |
Yes @harsid17! Since you're accessing resources outside of the repo where you are running your action, you will have to create a secret in this repo with a PAT that you generate and refer to that. The This would be a good use case for the newer "fine-grained" PATs, otherwise a PAT that you create would have access to ALL repositories that you have access to, and with the fine-grained PAT, you can only give it access to Then something like this: env:
GH_TOKEN: ${{ secrets.MY_PAT }}
REPO_TWO: 'some-other-private-repo` |
that makes sense. Is there a way to authenticate without needing a PAT? Wondering as both private repos are under an organization with limited to no access to generating/storing secrets other than those provided |
Yes @harsid17! The better way is to use a GitHub app: temporary generated authentication that doesn't rely on an individual user. See my other post for an example of how you could implement this in Actions. But you would need to have an administrator in the organization install the app on the target repository for you 😢 . |
This is great, thanks so much! |
This has been a really helpful resource! There are a few things I'd like to add, which may help other users of GitHub Enterprise:
|
Great tip @IdiosApps on the |
How to use gh auth login CLI Programmatically in GitHub Actions | josh-ops
Using the gh cli to programmatically authenticate in GitHub Actions
https://josh-ops.com/posts/gh-auth-login-in-actions/
The text was updated successfully, but these errors were encountered: