Skip to content

Commit

Permalink
Merge branch 'main' into zw/token-warn-update
Browse files Browse the repository at this point in the history
  • Loading branch information
zwhitfield3 committed Apr 9, 2024
2 parents ab82a57 + d6a201e commit 2b580fd
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
62 changes: 62 additions & 0 deletions .github/workflows/ctc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: ctc

on:
workflow_dispatch:
workflow_call:

jobs:
create-ctc-lock:
runs-on: ubuntu-latest
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 }}", "component_name": "${{ vars.TPS_API_APP_ID }}"}}' \
${{ vars.TPS_API_URL_PARAM }}/api/ctc`
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 }}", "component_name": "${{ vars.TPS_API_APP_ID }}"}}' \
${{ vars.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 }}")
2 changes: 1 addition & 1 deletion .github/workflows/start-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ jobs:
uses: ./.github/workflows/direwolf.yml
secrets: inherit
with:
releaseChannel: ${{ needs.get-version-channel.outputs.channel }}
releaseChannel: ${{ needs.get-version-channel.outputs.channel }}

0 comments on commit 2b580fd

Please sign in to comment.