-
Notifications
You must be signed in to change notification settings - Fork 164
81 lines (80 loc) · 2.8 KB
/
add-pr-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
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
name: Add PR to obs-docs board
on:
pull_request_target:
types: [review_requested]
branches:
- 'main'
permissions:
contents: read
jobs:
specific_review_requested:
name: Adding
runs-on: ubuntu-latest
# The steps below only run for PRs where `obs-docs` has been added as a reviewer
if: ${{ github.event.requested_team.name == 'obs-docs'}}
steps:
- name: Get token
id: get_token
uses: elastic/actions-app-token@master
with:
APP_PEM: ${{ secrets.OBS_DOCS_AUTOMATION_PRIVATE_KEY }}
APP_ID: 203735
- name: Add PR to board
uses: octokit/graphql-action@v2.x
id: add_pr_to_board
with:
query: |
mutation($project:ID!, $pull_request:ID!){
addProjectV2ItemById(input:{projectId:$project contentId:$pull_request}) {
item {
... on ProjectV2Item {
id
}
}
}
}
project: ${{ env.PROJECT_ID }}
pull_request: ${{ github.event.pull_request.node_id }}
env:
PROJECT_ID: "PVT_kwDOAGc3Zs0iZw"
GITHUB_TOKEN: ${{ steps.get_token.outputs.app_token }}
- name: Move PR to review column
uses: octokit/graphql-action@v2.x
id: move_pr_to_review_column
with:
headers: '{"GraphQL-Features": "projects_next_graphql"}'
query: |
mutation label_team($project:ID!, $item:ID!, $field:ID!, $value:String!){
updateProjectV2ItemFieldValue(input: { projectId:$project itemId:$item fieldId:$field value:{singleSelectOptionId: $value} }) {
projectV2Item {
id
content {
... on PullRequest {
number
}
}
}
}
}
project: ${{ env.PROJECT_ID }}
# `item` is the ID returned by the previous step
item: ${{ fromJSON(steps.add_pr_to_board.outputs.data).addProjectV2ItemById.item.id }}
# This is the ID for the project "status" attribute
field: "PVTSSF_lADOAGc3Zs0iZ84AAQIU"
# This is the ID for the status sub-attribute "In Progress"
value: "47fc9ee4"
env:
PROJECT_ID: "PVT_kwDOAGc3Zs0iZw"
GITHUB_TOKEN: ${{ steps.get_token.outputs.app_token }}
- name: Add label
uses: actions/github-script@v7
id: add_label
with:
github-token: ${{ steps.get_token.outputs.app_token }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['needs-writer-review']
})