-
Notifications
You must be signed in to change notification settings - Fork 61
proof of concept for GitHub action that opens an issue for a PR #937
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
Draft
trz42
wants to merge
2
commits into
EESSI:2023.06-software.eessi.io
Choose a base branch
from
trz42:create_issue_on_pr_open
base: 2023.06-software.eessi.io
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Create Issue on PR Opened | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
issues: write # to create an associated issue (if necessary) | ||
|
||
jobs: | ||
create-issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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|none so we would just need: permissions:
contents: read # to fetch code (actions/checkout)
issues: write # to create an associated issue (if necessary) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 47e14cf |
||
script: | | ||
const title = `New PR opened: #${context.payload.pull_request.number} - ${context.payload.pull_request.title}`; | ||
const body = ` | ||
A new pull request has been opened! | ||
|
||
**Title:** ${context.payload.pull_request.title} | ||
**Author:** ${context.payload.pull_request.user.login} | ||
|
||
**Link to PR:** ${context.payload.pull_request.html_url} | ||
|
||
<details><summary>Click for details & help</summary> | ||
|
||
Authorized maintainers may send commands by adding new comments to this issue. A comment can contain multiple commands each starting at the beginning of a line and having the format <code>bot: COMMANDS [ARGS]</code> | ||
|
||
The table below lists the commands that are currently supported: | ||
| command | description | | ||
| ------- | ----------- | | ||
| help | prints short usage information | | ||
| show_config | shows config information | | ||
| status | shows status information of builds | | ||
| build ARGS | instructs to build software as defined by the linked PR and with the one or more of the arguments:<br/>architecture, instance, repository, accelerator, exportvariable | | ||
|
||
For more information see [building software for EESSI](https://www.eessi.io/docs/bot/#build-test-deploy-bot) | ||
</details> | ||
`; | ||
|
||
const issue = await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: title, | ||
body: body, | ||
}); | ||
|
||
console.log(`Created issue: ${issue.data.html_url}`); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
This pr includes the new filter #949