Fix CI not preserving the "View deployment" button for old build links in PRs

This commit is contained in:
Keavon Chambers 2026-04-23 16:16:23 -07:00
parent f42d12da9e
commit 1444c333ab
1 changed files with 14 additions and 1 deletions

View File

@ -153,12 +153,18 @@ jobs:
if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then
REF="latest-stable" REF="latest-stable"
ENVIRONMENT="graphite-editor (Production)" ENVIRONMENT="graphite-editor (Production)"
AUTO_INACTIVE="true"
TRANSIENT_ENVIRONMENT="false"
elif [ "${{ github.event_name }}" = "push" ]; then elif [ "${{ github.event_name }}" = "push" ]; then
REF="master" REF="master"
ENVIRONMENT="graphite-dev (Production)" ENVIRONMENT="graphite-dev (Production)"
AUTO_INACTIVE="true"
TRANSIENT_ENVIRONMENT="false"
else else
REF="${{ inputs.checkout_ref || github.head_ref || github.ref_name }}" REF="${{ inputs.checkout_ref || github.head_ref || github.ref_name }}"
ENVIRONMENT="graphite-dev (Preview)" ENVIRONMENT="graphite-dev (Preview)"
AUTO_INACTIVE="false"
TRANSIENT_ENVIRONMENT="true"
fi fi
create_deployment() { create_deployment() {
gh api \ gh api \
@ -167,7 +173,14 @@ jobs:
repos/${{ github.repository }}/deployments \ repos/${{ github.repository }}/deployments \
--input - \ --input - \
--jq '.id' <<EOF --jq '.id' <<EOF
{"ref":"$1","environment":"$ENVIRONMENT","auto_merge":false,"required_contexts":[]} {
"ref": "$1",
"environment": "$ENVIRONMENT",
"auto_merge": false,
"required_contexts": [],
"auto_inactive": $AUTO_INACTIVE,
"transient_environment": $TRANSIENT_ENVIRONMENT
}
EOF EOF
} }
# Try branch name first (needed for GitHub's PR "View deployment" button), fall back to commit SHA if the branch was deleted # Try branch name first (needed for GitHub's PR "View deployment" button), fall back to commit SHA if the branch was deleted