proof of concept for GitHub action that opens an issue for a PR#937
proof of concept for GitHub action that opens an issue for a PR#937trz42 wants to merge 2 commits intoEESSI:2023.06-software.eessi.iofrom
Conversation
|
Instance
|
|
Instance
|
|
Instance
|
|
Instance
|
| - name: Create an issue | ||
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
We better explicitly define the permissions in the workflow file. This is the full set available:
permissions:
actions: read|write|none
attestations: read|write|none
checks: read|write|none
contents: read|write|none
deployments: read|write|none
id-token: write|none
issues: read|write|none
discussions: read|write|none
packages: read|write|none
pages: read|write|none
pull-requests: read|write|none
repository-projects: read|write|none
security-events: read|write|none
statuses: read|write|noneso we would just need:
permissions:
contents: read # to fetch code (actions/checkout)
issues: write # to create an associated issue (if necessary)|
|
||
| on: | ||
| pull_request: | ||
| types: [opened] |
There was a problem hiding this comment.
I think @laraPPr has played around with this to only trigger when certain file types are touched (in our case easystack files)
There was a problem hiding this comment.
We should limit that, yes. Only easystack files may be too few, though. Should be easy to figure out for which files bot jobs need to run.
There was a problem hiding this comment.
I was using this action for that https://github.com/dorny/paths-filter. I'm now looking to see if I can strip what we need from in it. So that we don't have to rely on external actions that much.
|
I think this will work but I am not sure it is necessary. If the bot has permission to write a comment in an issue, it also has permission to create the issue in the first place. It may save you from a race between bots to create an issue, but it also adds another step to configuring the bot. |
Hmm, don't really see the additional configuration step. What happens now is the following:
What has to be changed on the bot side is "only" figuring out which issue corresponds to the PR if any exists. If such an issue is identified it would use that to create comments. If commands are sent from the issue, this is easy. If they are sent from PR commands we need to implement some means to find it, e.g., searching for or accessing issues that reference the PR. There we would have to avoid that other issues referencing the PR might be found ... To avoid such complications, I'd change the bot code such that it doesn't act if the command is sent from a comment to the PR. This needs to be investigated a little more. Ideally one can link the PR and the Issue in a simple easily verifiable way. |
|
@trz42 Can you retarget this pr? |
Making it a draft for now. Just a first attempt to automatically create an issue for a PR that is opened. We might want to add some convention that a PR that needs involvement of the build bot contains some specific keywords in the description or in the title and add some logic to the action such that it not always creates an issue.
Example of its use via trz42#81