-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (66 loc) · 3.1 KB
/
Copy pathsync-roadmap.yml
File metadata and controls
73 lines (66 loc) · 3.1 KB
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
name: Sync roadmap
on:
push:
pull_request:
types: [opened, edited, synchronize, reopened, closed]
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Build payload
id: payload
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
REPOSITORY: ${{ github.repository }}
REF_NAME: ${{ github.ref_name }}
SHA: ${{ github.sha }}
ACTOR: ${{ github.actor }}
SERVER_URL: ${{ github.server_url }}
TOKEN: ${{ secrets.ROADMAP_WEBHOOK_TOKEN }}
run: |
set -euo pipefail
test -f "$GITHUB_EVENT_PATH"
if [ "$EVENT_NAME" = "push" ]; then
jq -n \
--arg token "$TOKEN" \
--arg event_type "push" \
--arg repository "$REPOSITORY" \
--arg branch "$REF_NAME" \
--arg sha "$SHA" \
--arg commit_message "$(jq -r '.head_commit.message // ""' "$GITHUB_EVENT_PATH")" \
--arg author "$(jq -r '.head_commit.author.name // env.ACTOR' "$GITHUB_EVENT_PATH")" \
--arg timestamp "$(jq -r '.head_commit.timestamp // (now | todateiso8601)' "$GITHUB_EVENT_PATH")" \
--arg commit_url "$SERVER_URL/$REPOSITORY/commit/$SHA" \
'{token:$token,event_type:$event_type,repository:$repository,branch:$branch,sha:$sha,commit_message:$commit_message,author:$author,timestamp:$timestamp,commit_url:$commit_url}' \
> payload.json
else
jq -n \
--arg token "$TOKEN" \
--arg event_type "pull_request" \
--arg action "$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" \
--arg repository "$REPOSITORY" \
--arg pr_number "$(jq -r '.number // ""' "$GITHUB_EVENT_PATH")" \
--arg pr_url "$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" \
--arg pr_title "$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" \
--arg pr_body "$(jq -r '.pull_request.body // ""' "$GITHUB_EVENT_PATH")" \
--arg branch "$(jq -r '.pull_request.head.ref // ""' "$GITHUB_EVENT_PATH")" \
--arg timestamp "$(jq -r '.pull_request.updated_at // (now | todateiso8601)' "$GITHUB_EVENT_PATH")" \
--argjson merged "$(jq -r '.pull_request.merged // false' "$GITHUB_EVENT_PATH")" \
'{token:$token,event_type:$event_type,action:$action,repository:$repository,pr_number:$pr_number,pr_url:$pr_url,pr_title:$pr_title,pr_body:$pr_body,branch:$branch,timestamp:$timestamp,merged:$merged}' \
> payload.json
fi
jq 'del(.token)' payload.json
- name: Send to roadmap
env:
ROADMAP_WEBHOOK_URL: ${{ secrets.ROADMAP_WEBHOOK_URL }}
run: |
set -euo pipefail
test -n "$ROADMAP_WEBHOOK_URL"
curl --fail-with-body --silent --show-error \
--request POST \
--header 'Content-Type: application/json' \
--data @payload.json \
"$ROADMAP_WEBHOOK_URL"