-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (50 loc) · 1.63 KB
/
project-bot.yaml
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
name: Add a new item to project
on:
issues:
types:
- opened
pull_request_target:
types:
- opened
jobs:
add_item:
runs-on: ubuntu-latest
steps:
- name: Issue an access token
uses: actions/create-github-app-token@v1
id: app-token
with:
app_id: ${{ secrets.PROJECT_APP_ID }}
private_key: ${{ secrets.PROJECT_APP_PEM }}
- name: Get project data
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
ORGANIZATION: topolvm
PROJECT_NUMBER: "2"
run: |
proj_id="$(gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
}
}
}' -F org=$ORGANIZATION -F number=$PROJECT_NUMBER --jq '.data.organization.projectV2.id')"
echo "PROJECT_ID=${proj_id}" >> $GITHUB_ENV
- name: Add an item to project
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
if [ ${{ github.event_name }} = issues ]; then
CONTENT_ID=${{ github.event.issue.node_id }}
else
CONTENT_ID=${{ github.event.pull_request.node_id }}
fi
gh api graphql -f query='
mutation($project:ID!, $contentId:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $contentId}) {
item {
id
}
}
}' -F project=$PROJECT_ID -F contentId=$CONTENT_ID --jq '.data.addProjectV2ItemById.item.id'