-
Notifications
You must be signed in to change notification settings - Fork 227
63 lines (58 loc) · 2.08 KB
/
ctc.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
name: ctc
on:
workflow_dispatch:
workflow_call:
jobs:
create-ctc-lock:
runs-on: ubuntu-latest
environment: ChangeManagement
steps:
- uses: actions/checkout@v3
- name: Call CTC API TO Create Lock
id: create-lock
run: |
CODE=`curl --w '%{http_code}' \
-X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Token ${{ secrets.TPS_API_TOKEN_PARAM }}" \
-d '{"lock": {"sha": "${{ github.sha }}", "app_id": "${{ secrets.TPS_API_APP_ID }}"}}' \
${{ secrets.TPS_API_URL_PARAM }}`
echo "STATUS_CODE=$CODE" >> $GITHUB_ENV
echo "Response status code is $CODE."
- name: Retry if TPS returns 409
env:
RETRY_LATER: "409"
uses:
nick-fields/retry@v2
if: ${{ env.STATUS_CODE == env.RETRY_LATER}}
with:
max_attempts: 15
warning_on_retry: true
retry_wait_seconds: 3600
retry_on_exit_code: 1
timeout_minutes: 3600
command: |
CODE=`curl --w '%{http_code}' \
-X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Token ${{ secrets.TPS_API_TOKEN_PARAM }}" \
-d '{"lock": {"sha": "${{ github.sha }}", "app_id": "${{ secrets.TPS_API_APP_ID }}"}}' \
${{ secrets.TPS_API_URL_PARAM }}/api/ctc`
echo "Response status code is $CODE"
if [ $CODE == "409" ]
then
exit 1
else
echo "STATUS_CODE=$CODE" >> $GITHUB_ENV
fi
- name: Verify CTC Lock Did Not Fail for Other Reasons
env:
UPDATE_LOCK_SUCCESS: "200"
NEW_LOCK_SUCCESS: "201"
if: ${{ env.STATUS_CODE != env.NEW_LOCK_SUCCESS && env.STATUS_CODE != env.UPDATE_LOCK_SUCCESS}}
uses: actions/github-script@v6
with:
script: |
core.setFailed("Failed to create CTC lock with TPS with response code ${{ env.STATUS_CODE }}")