This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Add issues and pull requests to the current release project #2131
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
11558e8
Boilerplate stuff
smashwilson 2a003e2
Action body :zap:
smashwilson a0212d3
Workflow configuration
smashwilson 16dee86
Operate on pull requests that are opened, assigned, or merged
smashwilson 5a1de33
Filter based on action before our workflow
smashwilson 8e09d3a
Rename workflows to avoid a collision
smashwilson 4b0c551
Use a PAT with more scopes
smashwilson 272514b
Typo fix
smashwilson b079b75
Fire on pull request reopen
smashwilson 9834f7b
Fix the import
smashwilson 3da23b5
Pass the right secret
smashwilson 38e6200
Some GraphQL typos
smashwilson 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
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,18 @@ | ||
| FROM node:8-slim | ||
|
|
||
| LABEL "com.github.actions.name"="auto-sprint" | ||
| LABEL "com.github.actions.description"="Add opened pull requests and assigned issues to the current sprint project" | ||
| LABEL "com.github.actions.icon"="list" | ||
| LABEL "com.github.actions.color"="white" | ||
|
|
||
| # Copy the package.json and package-lock.json | ||
| COPY package*.json ./ | ||
|
|
||
| # Install dependencies | ||
| RUN npm ci | ||
|
|
||
| # Copy the rest of your action's code | ||
| COPY . / | ||
|
|
||
| # Run `node /index.js` | ||
| ENTRYPOINT ["node", "/index.js"] |
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,84 @@ | ||
| const {Toolkit} = require('actions-toolkit'); | ||
| const {withDefaults} = require('actions-toolkit/lib/graphql'); | ||
|
|
||
| Toolkit.run(async tools => { | ||
| // Re-authenticate with the correct secret. | ||
| tools.github.graphql = withDefaults(process.env.GRAPHQL_TOKEN); | ||
|
|
||
| // Ensure that the actor of the triggering action belongs to the core team | ||
| const actorLogin = tools.context.actor; | ||
| const teamResponse = await tools.github.graphql(` | ||
| query { | ||
| organization(login: "atom") { | ||
| team(slug: "github-package") { | ||
| members(first: 100) { | ||
| nodes { | ||
| login | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `); | ||
| if (!teamResponse.organization.team.members.nodes.some(node => node.login === actorLogin)) { | ||
| tools.exit.neutral('User %s is not in the github-package team. Thanks for your contribution!', actorLogin); | ||
| } | ||
|
|
||
| // Identify the active release board and its "In progress" column | ||
| const projectQuery = await tools.github.graphql(` | ||
| query { | ||
| repository(owner: "atom", name: "github") { | ||
| projects( | ||
| search: "Release" | ||
|
Contributor
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. Will the matching be case sensitive, then? And is this search only on the name of the project board?
Contributor
Author
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. The search is only on the name of the board: https://developer.github.com/v4/object/repository/, search for "projects"
I'm not sure if it's case sensitive or not, though? The one I tested with was an exact case match 🤔 |
||
| states: [OPEN] | ||
| first: 1 | ||
| orderBy: {field: CREATED_AT, direction: DESC} | ||
| ) { | ||
| nodes { | ||
| id | ||
| name | ||
| columns(first: 10) { | ||
| nodes { | ||
| id | ||
| name | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `); | ||
| const project = projectQuery.repository.projects.nodes[0]; | ||
| if (!project) { | ||
| tools.exit.failure('No open project found with a name matching "Release".'); | ||
| } | ||
| const column = project.columns.nodes.find(node => node.name === 'In progress'); | ||
| if (!column) { | ||
| tools.exit.failure('No column found in the project %s with a name of exactly "In progress".', project.name); | ||
| } | ||
|
|
||
| // Add the issue/pull request to the sprint board | ||
| await tools.github.graphql(` | ||
| mutation ProjectCardAddition($columnID: ID!, $issueishID: ID!) { | ||
| addProjectCard(input: {projectColumnId: $columnID, contentId: $issueishID}) { | ||
| clientMutationId | ||
| } | ||
| } | ||
| `, { | ||
| columnID: column.id, | ||
| issueishID: tools.context.event === 'issues' | ||
| ? tools.context.payload.issue.node_id | ||
| : tools.context.payload.pull_request.node_id, | ||
| }); | ||
| tools.exit.success('Added as a project card.'); | ||
| }, { | ||
| event: [ | ||
| 'issues.assigned', | ||
| 'pull_request.opened', | ||
| 'pull_request.merged', | ||
| 'pull_request.assigned', | ||
| 'pull_request.reopened', | ||
| ], | ||
| secrets: ['GRAPHQL_TOKEN'], | ||
| }); | ||
Oops, something went wrong.
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.
How are "add" vs "consider" distinguished here?
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.
Basically, "consider" filters on the event's action to determine whether or not it should result in a release board addition; "add" does the actual addition.