-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
57 lines (56 loc) · 1.94 KB
/
action.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
name: 'Project Automation'
description: 'When a new issue or pull request is added to the repository, this action adds that to a project.'
inputs:
project_number:
description: 'The ID of the projects you want to use. Can be found in the URL for your project.'
required: true
organization:
description: 'The organization that the project that the project_number is referencing is created under.'
required: true
task_id:
description: 'The ID from the issue or pull request.'
required: true
repo-token:
description: 'Token used for automation.'
required: true
runs:
using: "composite"
steps:
- name: 'Get project data'
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.repo-token }}
ORGANIZATION: ${{ inputs.organization }}
PROJECT_NUMBER: ${{ inputs.project_number }}
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
fields(first:20) {
nodes {
... on ProjectV2Field {
id
name
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
- name: 'Add to project'
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.repo-token }}
TASK_ID: ${{ inputs.task_id }}
run: |
gh api graphql -f query='
mutation($project:ID!, $id:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $id}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f id=$TASK_ID --jq '.data.addProjectV2Item.projectV2Item.id'