-
-
Notifications
You must be signed in to change notification settings - Fork 137
131 lines (131 loc) · 5.04 KB
/
AddIssueToMilestoneProject.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Add Issues and Pull Requests To Milestone Project
on:
issues:
types: [milestoned]
jobs:
AddIssueToProject:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install @actions/core
- run: npm install @actions/github
- name: Get list of projects
uses: octokit/[email protected]
id: get-project-title
with:
query: |
query getTitle( $org:String!) {
organization(login:$org) {
projectsV2(first:100) {
nodes {
id
title
number
template
closed
owner {
id
}
}
}
}
}
org: RE-SS3D
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Check for existence of milestone project
uses: ./.github/actions/check-milestone-exists
id: check-milestone-exists
with:
JSON_LIST_OF_PROJECTS: ${{ steps.get-project-title.outputs.data }}
PROJECT_NAME: ${{ github.event.milestone.title }}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- run: "echo 'Existing project ID: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID }}'"
- run: "echo 'Project information: ${{ steps.get-project-title.outputs.data }}'"
- name: Add Issue to Milestone Project
uses: octokit/[email protected]
id: add-issue-to-milestone-project
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID != ''}}
with:
query: |
mutation AddToMilestone {
addProjectV2ItemById(input: {projectId:"${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID }}", contentId:"${{ github.event.issue.node_id }}" }) {
clientMutationId
item {
id
}
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Locate Status Column
uses: octokit/[email protected]
id: locate-status-column
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID != ''}}
with:
query: |
query getStatusColumn {
node(id:"${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID }}") {
... on ProjectV2 {
field(name: "Status") {
... on ProjectV2SingleSelectField {
id
}
}
}
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Get Backlog Id
uses: octokit/[email protected]
id: get-backlog-id
if: ${{ fromJSON(steps.locate-status-column.outputs.data).node.field.id != ''}}
with:
query: |
query getStatusColumn {
node(id:"${{ fromJSON(steps.locate-status-column.outputs.data).node.field.id }}") {
... on ProjectV2SingleSelectField {
options {
id
name
}
}
}
}
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: ${{ steps.determine-status-column.outputs.COLUMN }}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Add To correct column
uses: octokit/[email protected]
id: add-issue-to-correct-column
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID != ''}}
with:
query: |
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
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}