-
Notifications
You must be signed in to change notification settings - Fork 186
44 lines (42 loc) · 1.62 KB
/
add-issues-to-project.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
# GitHub action that automatically adds newly filed issues to the Lit project.
#
# Based on the example at
# https://docs.github.com/en/issues/trying-out-the-new-projects-experience/automating-projects#example-workflow-authenticating-with-a-personal-access-token
on:
issues:
types: [opened]
jobs:
add-issue-to-project:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# Finds the global entity ID for the project and adds it to an environment variable
# for the next step to consume.
- name: Get project ID
env:
GITHUB_TOKEN: ${{ secrets.LIT_ROBOT_AUTOMATION_PAT }}
ORGANIZATION: lit
PROJECT_NUMBER: 4
run: |
gh api graphql -f query='
query($organization: String!, $project_number: Int!) {
organization(login: $organization){
projectV2(number: $project_number) {
id
}
}
}' -f organization=$ORGANIZATION -F project_number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
- name: Add issue to project
env:
GITHUB_TOKEN: ${{ secrets.LIT_ROBOT_AUTOMATION_PAT }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql -f query='
mutation($project_id:ID!, $issue_id:ID!) {
addProjectV2ItemById(input: {projectId: $project_id, contentId: $issue_id}) {
item {
id
}
}
}' -f project_id=$PROJECT_ID -f issue_id=$ISSUE_ID