-
-
Notifications
You must be signed in to change notification settings - Fork 137
103 lines (103 loc) · 3.58 KB
/
CreateProjectWhenMilestoneCreated.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
name: Create Project When Milestone Created
on:
milestone:
types: [created]
jobs:
CreateProjectFromMilestone:
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 }}
- name: Duplicate Template Project
uses: octokit/[email protected]
id: duplicate-template-project
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID == '' }}
with:
query: |
mutation copyTheProject {
copyProjectV2(input: {ownerId:"MDEyOk9yZ2FuaXphdGlvbjQyNzc4NjQw", projectId:"PVT_kwDOAozAEM4AMVn2", title:"Example"}) {
clientMutationId
projectV2 {
id
}
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Setup Project
uses: octokit/[email protected]
id: setup-project
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID == ''}}
with:
query: |
mutation setupTheProject {
updateProjectV2(input: {projectId:"${{ fromJSON(steps.duplicate-template-project.outputs.data).copyProjectV2.projectV2.id }}", title:"${{ github.event.milestone.title }}", public:true}) {
clientMutationId
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Get repo ID
uses: octokit/[email protected]
id: get-repo-id
with:
query: |
query getRepo( $org:String!) {
repository(name:"SS3D", owner:$org) {
id
}
}
org: RE-SS3D
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}
- name: Link SS3D Repository to new Project
uses: octokit/[email protected]
id: link-project
if: ${{ steps.check-milestone-exists.outputs.EXISTING_PROJECT_ID == ''}}
with:
query: |
mutation LinkTheProject {
linkProjectV2ToRepository(input: {projectId:"${{ fromJSON(steps.duplicate-template-project.outputs.data).copyProjectV2.projectV2.id }}", repositoryId:"${{ fromJSON(steps.get-repo-id.outputs.data).repository.id }}" }) {
clientMutationId
}
}
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_MANAGEMENT_TOKEN }}