-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (40 loc) · 1.69 KB
/
force_push_to_uat.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
name: force_push_to_uat
on:
workflow_call:
jobs:
force_push_to_uat:
name: force_push_to_uat
if: startsWith(github.event.branches[0].name, 'release/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Output caller branch
run: echo ${{ github.event.branches[0].name }}
- name: Output tested commit
run: echo ${{ github.event.branches[0].commit.sha }}
- name: Determine status state
run: |
output=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.branches[0].commit.sha }}/status)
api_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "api") | .state')
e2e_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "e2e_be") | .state')
build_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "tide_build") | .state')
echo "API test status is $api_status"
echo "E2E test status is $e2e_status"
echo "Build status is $build_status"
if [[ $api_status == "success" && $e2e_status == "failure" && $build_status == "failure" ]]; then
echo "==> All checks passed, deploying to UAT."
exit 0
else
echo "==> Checks pending or failed, holding."
exit 1
fi
- name: Force push
run: |
cd ${GITHUB_WORKSPACE}
chmod +x .circleci/force-push-to-uat.sh
.circleci/force-push-to-uat.sh