-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrects columns of Pull Requests in milestone projects (#1199)
* Check which Project column a particular issue or pull request should be added to. * Amended the title. * Only needs to run on Issues (PR's are a subset) * Changed variable * x * Remove $ * Variables * issues * pull_request * Changed method of determining whether PR or issue. * Change to empty string rather than null. * Adds to the correct column (i.e. not necessarily the backlog column).
- Loading branch information
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
name: 'Determine Status Column' | ||
inputs: | ||
ISSUE_TITLE: | ||
description: 'Title of the Issue or Pull Request' | ||
required: true | ||
PULL_REQUEST_URL: | ||
description: 'Pull request URL (existence used to confirm whether pull request or issue)' | ||
required: true | ||
outputs: | ||
COLUMN: | ||
description: 'The appropriate column to place the issue in.' | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
This file contains 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,25 @@ | ||
const core = require('@actions/core'); | ||
const url = core.getInput('PULL_REQUEST_URL') | ||
const title = core.getInput('ISSUE_TITLE') | ||
|
||
var column = null | ||
console.log(url); | ||
console.log(title); | ||
|
||
if (url == "") { // If Pull Request URL is empty, the event must be an issue. | ||
column = "Backlog"; | ||
} | ||
else // Otherwise, it's a pull request. | ||
{ | ||
var potentialPrefix = title.toUpperCase().slice(0, 5); | ||
console.log(potentialPrefix); | ||
if (potentialPrefix == "[WIP]") { | ||
column = "In Progress"; | ||
} | ||
else | ||
{ | ||
column = "In Review"; | ||
} | ||
} | ||
console.log(column); | ||
core.setOutput('COLUMN', column); |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Add Issue To Milestone Project | ||
name: Add Issues and Pull Requests To Milestone Project | ||
on: | ||
issues: | ||
types: [milestoned] | ||
|
@@ -102,21 +102,27 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }} | ||
- run: "echo 'Field options: ${{ steps.get-backlog-id.outputs.data }}'" | ||
- name: Determine status column | ||
uses: ./.github/actions/determine-status-column | ||
id: determine-status-column | ||
with: | ||
PULL_REQUEST_URL: ${{ github.event.issue.pull_request.url }} | ||
ISSUE_TITLE: ${{ github.event.issue.title }} | ||
- name: Get target field ID | ||
uses: ./.github/actions/get-single-select-field-id | ||
id: get-single-select-field-id | ||
with: | ||
JSON_FIELD_OPTIONS: ${{ steps.get-backlog-id.outputs.data }} | ||
TARGET_OPTION: Backlog | ||
TARGET_OPTION: ${{ steps.determine-status-column.outputs.COLUMN }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }} | ||
- name: Add To Backlog | ||
- name: Add To correct column | ||
uses: octokit/[email protected] | ||
id: add-issue-to-backlog-column | ||
id: add-issue-to-correct-column | ||
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID != ''}} | ||
with: | ||
query: | | ||
mutation AddToBacklog { | ||
mutation AddToCorrectColumn { | ||
updateProjectV2ItemFieldValue(input: {projectId:"${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID }}", itemId:"${{ fromJSON(steps.add-issue-to-milestone-project.outputs.data).addProjectV2ItemById.item.id }}", fieldId: "${{ fromJSON(steps.locate-status-column.outputs.data).node.field.id }}", value: { singleSelectOptionId: "${{steps.get-single-select-field-id.outputs.OPTION_ID}}" }}) { | ||
clientMutationId | ||
} | ||
|