Skip to content

Commit

Permalink
Refresh CTC workflow (#2802)
Browse files Browse the repository at this point in the history
* change component_name to app_id

* remove api/ctc

* Fixes to get job running

* Clarify terminology in CTC workflow

* Update required actions for Node 20 compat

* Improve the lock retry timing

* Check CTC before create-cli-release

* Switch CTC check to use component name

* Switch TPS integration to component_slug

---------

Co-authored-by: Mars Hall <[email protected]>
  • Loading branch information
angeldcampbell and mars authored Oct 30, 2024
1 parent 0bce57c commit e4aa1c6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/create-cli-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
default: false

jobs:
check-for-moratorium:
if: fromJSON(inputs.isStableCandidate)
uses: ./.github/workflows/ctc.yml

get-version-channel:
runs-on: ubuntu-latest
outputs:
Expand Down
63 changes: 34 additions & 29 deletions .github/workflows/ctc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,59 @@ on:
workflow_call:

jobs:
create-ctc-lock:
# Use TPS service to get clearance to release from Salesforce Change-Traffic-Control:
# https://github.com/heroku/tps/blob/master/docs/ctc.md
check-tps-for-lock:
runs-on: ubuntu-latest
environment: ChangeManagement
steps:
- uses: actions/checkout@v3
- name: Call CTC API TO Create Lock
id: create-lock
- uses: actions/checkout@v4
- name: Check tps.heroku.tools for lock
id: check-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": "${{ secrets.TPS_API_APP_ID }}"}}' \
${{ secrets.TPS_API_URL_PARAM }}/api/ctc`
echo "STATUS_CODE=$CODE" >> $GITHUB_ENV
echo "Response status code is $CODE."
STATUS_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_slug": "cli"}}' \
https://tps.heroku.tools/api/ctc)"
echo "Response status code is $STATUS_CODE."
echo "STATUS_CODE=$STATUS_CODE" >> $GITHUB_ENV
- name: Retry if TPS returns 409
- name: Retry if lock cannot be obtained
id: retry-lock
env:
RETRY_LATER: "409"
uses:
nick-fields/retry@v2
nick-fields/retry@v3
if: ${{ env.STATUS_CODE == env.RETRY_LATER}}
with:
max_attempts: 15
max_attempts: 12
warning_on_retry: true
retry_wait_seconds: 3600
retry_wait_seconds: 300
retry_on_exit_code: 1
timeout_minutes: 3600
timeout_seconds: 60
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": "${{ secrets.TPS_API_APP_ID }}"}}' \
${{ secrets.TPS_API_URL_PARAM }}/api/ctc`
STATUS_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_slug": "cli"}}' \
https://tps.heroku.tools/api/ctc)"
echo "Response status code is $CODE"
if [ $CODE == "409" ]
echo "Response status code is $STATUS_CODE"
if [ $STATUS_CODE == "409" ]
then
exit 1
else
echo "STATUS_CODE=$CODE" >> $GITHUB_ENV
echo "STATUS_CODE=$STATUS_CODE" >> $GITHUB_ENV
fi
- name: Verify CTC Lock Did Not Fail for Other Reasons
- name: Verify lock status
id: verify-lock
env:
UPDATE_LOCK_SUCCESS: "200"
NEW_LOCK_SUCCESS: "201"
Expand Down
2 changes: 1 addition & 1 deletion scripts/postrelease/change_management
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function sendDeployNotification () {
release: {
actor_email: actorEmail,
app_id: appId,
component_name: 'cli',
component_slug: 'cli',
description: `Deploy ${sha} of heroku/cli in ${stage}`,
sha,
stage
Expand Down

0 comments on commit e4aa1c6

Please sign in to comment.