-
Notifications
You must be signed in to change notification settings - Fork 4
79 lines (68 loc) · 2.13 KB
/
change_ticket_status_done.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
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
name: Change Ticket Status to Done
on:
pull_request:
types: [closed]
branches-ignore:
- swagger-ui-updates
jobs:
change_ticket_status_to_done_if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Change the status of corresponding Notion Ticket to Done
env:
DATABASE_ID: 35e838520c274894b2206eb34a198575
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
run: |
branch_name="${{ github.event.pull_request.head.ref }}"
if [[ $branch_name =~ DANG-([0-9]+)$ ]]; then
TASK_ID="${BASH_REMATCH[1]}"
echo "Task ID number: $TASK_ID"
else
echo "Branch 이름에서 Task ID number 정보를 찾을 수 없습니다."
exit 1
fi
JSON_DATA=$(cat <<EOF
{
"filter": {
"property": "Task ID",
"unique_id": {
"equals": $TASK_ID
}
}
}
EOF
)
response=$(
curl -X POST "https://api.notion.com/v1/databases/${DATABASE_ID}/query" \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
--data "$JSON_DATA"
)
echo "$response" | jq .
PAGE_ID=$(echo $response | jq -r ".results[0].id")
if [ "$PAGE_ID" == "null" ]; then
echo "$PAGE_ID Ticket이 존재하지 않습니다."
exit 1
fi
JSON_DATA=$(cat <<EOF
{
"properties": {
"Status": {
"status": {
"name": "Done"
}
}
}
}
EOF
)
response=$(
curl -X PATCH "https://api.notion.com/v1/pages/${PAGE_ID}" \
-H "Authorization: Bearer ${NOTION_API_KEY}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
--data "$JSON_DATA"
)
echo "$response" | jq .