-
Notifications
You must be signed in to change notification settings - Fork 33
78 lines (71 loc) · 2.48 KB
/
deploy.yml
File metadata and controls
78 lines (71 loc) · 2.48 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
74
75
76
77
78
name: Trigger Builds on Release
# Trigger builds on okd only on new releases
# Assumes the branch is "master"
# Uses secrets.OKD_BUILD_HOOK to know where to send the event to
# OKD_BUILD_HOOK should be a generic build hook
on:
release:
types:
- released
jobs:
trigger_build:
name: trigger build
runs-on: ubuntu-latest
steps:
# Grab committer and author information from the commit
- name: get commit
id: commit
run: |
commit_url=$(
jq -r '.repository.git_commits_url' $GITHUB_EVENT_PATH |
sed 's/{.*}/\/${{ github.sha }}/'
)
curl --request GET \
--silent \
--show-error \
--url "$commit_url" \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--fail > commit-out
jq -C '.' commit-out
echo "::set-output name=committer::$(jq -c '.committer' commit-out)"
echo "::set-output name=author::$(jq -c '.author' commit-out)"
# Construct the json blob as per okd's webhook requirements
- name: format payload
run: |
cat $GITHUB_EVENT_PATH | \
jq '{
git: {
uri: .repository.html_url,
ref: "master",
commit: "${{ github.sha }}",
author: ${{ steps.commit.outputs.author }},
committer: ${{ steps.commit.outputs.committer }}
}
}' | \
tee payload.json | \
jq -C '.'
# send the webhook
- name: trigger build
id: hook
env:
OKD_BUILD_HOOK: ${{ secrets.OKD_BUILD_HOOK }}
run: |
curl \
--insecure \
--silent \
--show-error \
--header "Content-Type: application/json" \
--request POST \
--data @payload.json "$OKD_BUILD_HOOK" > curl-out
jq -C '.' curl-out || (cat curl-out; false)
echo "::set-output name=kind::$(jq '.kind' curl-out)"
# Fail if we recieved a Status response and it doesn't look good
- name: test http code
if: steps.hook.outputs.kind == 'Status'
run: "[ `jq '.code' curl-out` -lt 400 ]"
- name: test status
if: steps.hook.outputs.kind == 'Status'
run: "[ `jq '.status' curl-out` == 'Success' ]"
- name: test if skipped
if: steps.hook.outputs.kind == 'Status'
run: "[[ `jq '.message' curl-out` != *skipping* ]]"