Skip to content

backend/DANG-1249: 정적 팩토리 메서드로 객체 생성하도록 변경 #688

backend/DANG-1249: 정적 팩토리 메서드로 객체 생성하도록 변경

backend/DANG-1249: 정적 팩토리 메서드로 객체 생성하도록 변경 #688

name: Link PR to Ticket
on:
pull_request:
types: [opened]
jobs:
link_pr_to_ticket:
runs-on: ubuntu-latest
steps:
- name: Set PR URL to corresponding Notion Ticket
env:
PR: ${{ github.event.pull_request.html_url }}
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": {
"GitHub Pull Requests": {
"url": "$PR"
},
"Status": {
"status": {
"name": "Reviewing"
}
}
}
}
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 .