-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix: skip permission verification exception when Github Apps #272
Conversation
lib/verify.js
Outdated
// have all permissions required for @semantic-release/github to work | ||
if (env.GITHUB_ACTION) { | ||
if (env.GITHUB_ACTION || env.GITHUB_APP) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does the GITHUB_APP
environment variable come from? If it's a custom environment variable that you set in your particular case, then I don't think we should add a check for it to semantic-release
Can you share your semantic-release setup? I wonder how you create an installation access token and pass it to semantic release :) |
This is running in Jenkins with the new auth method for the Github plugin. See https://www.jenkins.io/blog/2020/04/16/github-app-authentication/ Example:
Github Apps create installation tokens the same way Github Actions do. These tokens have short expiration time. The flag will need to be provided as an extra environment variable. Something like the following:
Github Apps have lots of advantages over personal access tokens. Higher rate limits, scopes permissions,... |
Is see. I wish there was a way to check if the current installation has access and the required permissions, but I don't think there is right now. I suggest to add a |
That should work. I will try to add that flag. |
Good point, I think we shouldn't skip all the verifications, only the permissions verifications 🤔 I have another idea. We could send a request that is guaranteed to succeed when authenticated as an installation, but fail otherwise. I would suggest we send a What I would like to try is the following: If // If authenticated as GitHub App installation, `push` will always be false.
// We send another request to check if current authentication is an installation.
// Note: we cannot check if the installation has all required permissions, it's
// up to the user to make sure it has
if (await github.request('HEAD /installation/repositories', { per_page: 1 }).catch(() => return false) {
return
} I think I'd prefer doing that check to address your specific use case, over adding a new configuration option. What do you think? For testing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good 👍
🎉 This PR is included in version 7.0.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@gr2m I don't think this is working as expected. "Accept: application/vnd.github.machine-man-preview+json" is needed in installation/repositories. How do you handle that? |
And there is an issue in the semantic-release repo aswell, which needs to be solved like semantic-release/semantic-release@cb2c506 |
Similar to Github Actions, when using installation tokens from Github Apps the verification should be skipped.
Should we use a more generic flag for skipping the permission validation? e.g.
SKIP_PERMISSIONS
?I will add the relevant docs to the Readme once I get the ok.