Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh CTC workflow #2802

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
mars marked this conversation as resolved.
Show resolved Hide resolved
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
Loading