-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (63 loc) · 2.66 KB
/
trigger_aio.yml
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: Trigger RobotFramework AIO
on:
pull_request:
types:
- closed
- opened
- synchronize
branches:
- develop
env:
GH_TOKEN: ${{ github.token }}
jobs:
trigger-build-aio:
runs-on: ubuntu-latest
steps:
- name: Trigger RobotFramework AIO
run: |
# Get branch created merge request
PULL_REQUEST_BRANCH="${{ github.head_ref }}"
curl -X POST https://api.github.com/repos/test-fullautomation/RobotFramework_AIO/dispatches \
--header 'authorization: Bearer ${{ secrets.PAT_THONG }}' \
-H 'Accept: application/vnd.github.everest-preview+json' \
--data '{"event_type": "TRIGGER_AIO", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "branch": "'"$PULL_REQUEST_BRANCH"'" }}'
status-build-aio:
runs-on: ubuntu-latest
needs: trigger-build-aio
timeout-minutes: 90 # Timeout after 90 minutes
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Wait for Build AIO Pipeline Completion
id: wait-for-pipeline
run: |
# Get the recently triggered pipeline ID
PIPELINE_ID=$(gh api repos/test-fullautomation/RobotFramework_AIO/actions/runs --jq '.workflow_runs | sort_by(.created_at) | last | .id')
echo $PIPELINE_ID > pipeline_id.txt
# Check the status of the PIPELINE_ID in a loop
while [[ "$(gh api repos/test-fullautomation/RobotFramework_AIO/actions/runs/$PIPELINE_ID --jq '.status')" != "completed" ]]; do
sleep 60 # If not completed, wait for 60 seconds and check again.
done
- name: Get pipeline result
id: pipeline
run: |
# Read the PIPELINE_ID from the saved file
PIPELINE_ID=$(cat pipeline_id.txt)
# Get result of pipeline AIO
gh api repos/test-fullautomation/RobotFramework_AIO/actions/runs/$PIPELINE_ID --jq .conclusion > pipeline_status.txt
gh api repos/test-fullautomation/RobotFramework_AIO/actions/runs/$PIPELINE_ID --jq .html_url > pipeline_link.txt
- name: Report status
run: |
# Read result from the saved file
PIPELINE_STATUS=$(cat pipeline_status.txt)
PIPELINE_LINK=$(cat pipeline_link.txt)
# Check result pipeline and report
if [[ "$PIPELINE_STATUS" == "success" ]]; then
echo "Pipeline RobotFramework AIO success."
echo "Details at link: $PIPELINE_LINK"
else
echo "Pipeline RobotFramework AIO is not succeed."
echo "Details at link: $PIPELINE_LINK"
# Notify fail build AIO pipeline
exit 1
fi