-
Notifications
You must be signed in to change notification settings - Fork 48
69 lines (66 loc) · 2.82 KB
/
ost.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
#
# This is a reusable worflow to be triggered from other projects or manually.
# See example-trigger.yaml for how to use it in other projects.
# If you call this via a different trigger than on: issue_comment you can use the optional parameter:
# comment - full comment body, e.g. "/ost he-basic-suite-master el9stream"
#
name: OST trigger
on:
workflow_call:
inputs:
comment:
required: false
type: string
pr_url:
required: false
type: string
workflow_dispatch:
inputs:
pr_url:
required: true
type: string
comment:
required: true
default: "/ost basic-suite-master el9stream"
type: string
jobs:
trigger-ost:
runs-on: ost-trigger
timeout-minutes: 4
if: github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
( github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/ost') && (
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')
)
steps:
- name: trigger
env:
OST_APP_ID: 164117
PR_URL: "${{ github.event.issue.pull_request.url }}${{ inputs.pr_url }}"
COMMENT: "${{ github.event.comment.body }}${{ inputs.comment }}"
working-directory: /var/lib/nginx/gh
run: |
echo "$PR_URL" | grep '^https://api.github.com/repos/oVirt/'
echo "$COMMENT" | egrep '^/ost( [a-z\-]+( [a-z0-9]+)?)?$'
SUITE=$(echo "$COMMENT" | cut -d " " -s -f2)
DISTRO=$(echo "$COMMENT" | cut -d " " -s -f3)
SUITE=${SUITE:-basic-suite-master}
DISTRO=${DISTRO:-el9stream}
SHA=$(curl -sS ${PR_URL} | jq -r .head.sha)
CHECK_SUITES="$(curl -sS ${PR_URL} | jq -r .base.repo.url)/commits/${SHA}/check-suites"
BASE_TIME=$(curl -sS ${CHECK_SUITES} | jq -r ".check_suites[] | select(.app.id==${OST_APP_ID}) | select(.head_commit.id==\"${SHA}\") | .updated_at")
echo "last update: ${BASE_TIME:-no OST app report yet in list: $(curl -sS ${CHECK_SUITES} | jq .check_suites[].app.name)}"
echo "trigger content:"
{ echo "${PR_URL}"; echo "${SUITE}"; echo "${DISTRO}"; } | runuser -u nginx tee queue
i=0
while [ $i -lt 12 ]; do # 2 minutes
sleep 10
UPDATE_TIME=$(curl -sS ${CHECK_SUITES} | jq -r ".check_suites[] | select(.app.id==${OST_APP_ID}) | select(.head_commit.id==\"${SHA}\") | .updated_at")
[[ -z "$UPDATE_TIME" ]] && { echo "error getting update, skip"; UPDATE_TIME="$BASE_TIME"; }
echo "try #$((i++)): $UPDATE_TIME"
[[ "$BASE_TIME" != "$UPDATE_TIME" ]] && break
done
rm -f queue
[[ "$BASE_TIME" != "$UPDATE_TIME" ]] || { echo "Jenkins didn't pick it up"; exit 1; }