@@ -153,22 +153,38 @@ jobs:
153153 if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then
154154 REF="latest-stable"
155155 ENVIRONMENT="graphite-editor (Production)"
156+ AUTO_INACTIVE="true"
157+ TRANSIENT_ENVIRONMENT="false"
156158 elif [ "${{ github.event_name }}" = "push" ]; then
157159 REF="master"
158160 ENVIRONMENT="graphite-dev (Production)"
161+ AUTO_INACTIVE="true"
162+ TRANSIENT_ENVIRONMENT="false"
159163 else
160- REF="$(git rev-parse HEAD) "
164+ REF="${{ inputs.checkout_ref || github.head_ref || github.ref_name }} "
161165 ENVIRONMENT="graphite-dev (Preview)"
166+ AUTO_INACTIVE="false"
167+ TRANSIENT_ENVIRONMENT="true"
162168 fi
163- DEPLOY_ID=$(gh api \
164- -X POST \
165- -H "Accept: application/vnd.github+json" \
166- repos/${{ github.repository }}/deployments \
167- --input - \
168- --jq '.id' <<EOF
169- {"ref":"$REF","environment":"$ENVIRONMENT","auto_merge":false,"required_contexts":[]}
169+ create_deployment() {
170+ gh api \
171+ -X POST \
172+ -H "Accept: application/vnd.github+json" \
173+ repos/${{ github.repository }}/deployments \
174+ --input - \
175+ --jq '.id' <<EOF
176+ {
177+ "ref": "$1",
178+ "environment": "$ENVIRONMENT",
179+ "auto_merge": false,
180+ "required_contexts": [],
181+ "auto_inactive": $AUTO_INACTIVE,
182+ "transient_environment": $TRANSIENT_ENVIRONMENT
183+ }
170184 EOF
171- )
185+ }
186+ # Try branch name first (needed for GitHub's PR "View deployment" button), fall back to commit SHA if the branch was deleted
187+ DEPLOY_ID=$(create_deployment "$REF" 2>/dev/null) || DEPLOY_ID=$(create_deployment "$(git rev-parse HEAD)")
172188 gh api \
173189 -X POST \
174190 -H "Accept: application/vnd.github+json" \
@@ -188,9 +204,19 @@ jobs:
188204 exit 0
189205 fi
190206
207+ size_of() { find frontend/dist/assets "$@" -printf '%s\n' | awk '{s+=$1} END {printf "%.2f MB", s/1048576}'; }
208+ WASM_SIZE=$(size_of -name '*.wasm')
209+ JS_SIZE=$(size_of -name '*.js')
210+ CSS_SIZE=$(size_of -name '*.css')
211+ FONT_SIZE=$(size_of \( -name '*.woff2' -o -name '*.woff' -o -name '*.ttf' -o -name '*.otf' \))
212+ IMAGE_SIZE=$(size_of \( -name '*.png' -o -name '*.jpg' -o -name '*.svg' \))
213+ ALL_SIZE=$(size_of -type f)
214+
191215 COMMENT_BODY="| 📦 **Web Build Complete for** $(git rev-parse HEAD) |
192216 |-|
193- | $CF_URL |"
217+ | $CF_URL |
218+
219+ Wasm: **$WASM_SIZE** — JS: **$JS_SIZE** — CSS: **$CSS_SIZE** — Fonts: **$FONT_SIZE** — Images: **$IMAGE_SIZE** — All Assets: **$ALL_SIZE**"
194220
195221 if [ "${{ github.ref }}" = "refs/tags/latest-stable" ]; then
196222 # Push tag: skip commenting (commit was already commented on master merge)
0 commit comments