-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Backport workflow: Use access token to run CI on PRs? #9554
Comments
Instead of using a PAT, I'd recommend making a GitHub App and provisioning its credentials to the workflow via https://github.com/marketplace/actions/github-app-token + use environments feature in workflows so that the secrets are not global. Another hack I've been using is adding a deployment key to the repo + adding its private key as a secret. Then, in the workflows, add |
FWIW this seems like a good overview of possibilities (some of which @webknjaz has already mentioned): https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs |
Hey @The-Compiler, have I offered you to use my Patchback GitHub App? I don't remember if I did, but it so happened that a number of projects are using it successfully (some of which I didn't even know existed). |
I can easily do this one -- I will generate the key pair, add the private key as a secret and throw it away. Any other core dev wants to ack this (or add a key directly given my ack)? |
@bluetech please go ahead! Thanks! |
…cess token The builtin actions token is not allowed to trigger further workflows. So when we create a PR using that token, the PR checks don't run, and a maintainer must close & open the PR to make them run. This is quite annoying, so switch back to the "machine user" approach. Fixes pytest-dev#9554.
I realized after the fact what @webknjaz and the peter-evans/create-pr docs say, that a deploy key will only trigger |
That's not really accurate. If there is a PR for the given branch, the |
@bluetech I looked at your PR #10346, and now I see why you've drawn this connection. This is because both PR creation and pushing to Git used the same token. I've done one clever thing in one of my projects — the workflow first pushes an empty commit (push to a new branch happens), then a PR is created using a normal |
Reopening, see #10354... |
@webknjaz Heh that's indeed clever. We can try this if nothing else works. Slight downside is that it will create extra notifications for the last push, but that's not too bad. |
@bluetech have you considered just giving my bot a try instead? You can install Patchback on any test repo under your user account and see if it works for you, no need to experiment on this upstream repo. I have already put a lot of thought into it so you don't have to reinvent the wheel if there's no need. But if you want to stick with GHA, I'd recommend creating a GitHub App entity under this org and provisioning it's secrets to GHA, scoped to an environment. That would provide you with the most pleasing experience while still allowing you to use GHA is the main runtime (you'd get an API token to use via something like https://github.com/marketplace/actions/app-token). |
Out of curiosity I did take a look at the bot. Seems interesting, is there any documentation on how to use it? I dug around Is it a matter of just installing the bot and creating labels in the format |
@nicoddemus sorry, I missed your comment.
Oh, my... Sorry about that! The project kinda grew naturally and took weird turns. First, I had an idea of doing something like this + had some experiments with writing GitHub Apps. I thought I'd use it for aiohttp. Then, I didn't actually start the project. And, at some point, folks maintaining the community Ansible Collections were complaining about the cherry-picking process being annoying. So I remembered my idea and sketched the bot later that evening. I was testing it on those collection repositories, which is why I've just added the config there as it evolved. And later people were just copying it around so I completely forgot about the documentation.
And yes. You just install it (maybe in your fork or a test repo for testing) and create labels (I'd probably prefer to just auto-create them but never got time to work on such a feature). P.S. You might want also want to drop in a config for https://github.com/python/cherry-picker — it's originally written for CPython, but then it got integrated into aiohttp and Ansible. I don't use it anymore personally (although, I've contributed a lot at some point) but I know that many people do, and having a config facilitates this. This is an assistive tool specifically for creating backports from the dev machine. |
@nicoddemus hey, do you want to revisit this? |
This patch prepares the project's backporting process to start being handled by the Patchback GitHub App [[1]]. Ref pytest-dev#9384 Resolves pytest-dev#9385 Resolves pytest-dev#9553 Resolves pytest-dev#9554 Resolves pytest-dev#9555 [1]: https://github.com/apps/patchback
This patch prepares the project's backporting process to start being handled by the Patchback GitHub App [[1]]. Ref pytest-dev#9384 Resolves pytest-dev#9385 Resolves pytest-dev#9553 Resolves pytest-dev#9554 Resolves pytest-dev#9555 [1]: https://github.com/apps/patchback
Regarding CI not running, right - CI doesn't run when triggered this way - this also happens for the create-pull-request actions and similar. Workaround is to close & reopen, then it triggers. It's also possible to use a user token (pytestbot), but that has its own security considerations.
Originally posted by @bluetech in #9430 (comment)
The text was updated successfully, but these errors were encountered: