@@ -119,15 +119,6 @@ jobs:
119119 exit 1
120120 fi
121121
122- - name : Add deployment metadata
123- if : ${{ inputs.deployment_env == 'staging' }}
124- run : |
125- TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
126- mkdir -p meta
127- echo "$GITHUB_SHA deployed at $TIMESTAMP" > meta/.deployed.txt
128- echo "actor=$GITHUB_ACTOR repo=$GITHUB_REPOSITORY" >> meta/.deployed.txt
129- cp meta/.deployed.txt www/
130-
131122 - name : Compute safe repo name
132123 id : vars
133124 run : |
@@ -140,6 +131,21 @@ jobs:
140131 s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/staging/${GITHUB_SHA}/ \
141132 --delete --exact-timestamps
142133
134+ - name : Upload staging markers (.deployed.txt)
135+ run : |
136+ TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
137+ cat > .deployed.txt <<EOF
138+ sha=${GITHUB_SHA}
139+ env=staging
140+ ts=${TIMESTAMP}
141+ actor=${GITHUB_ACTOR}
142+ repo=${GITHUB_REPOSITORY}
143+ EOF
144+ aws s3 cp .deployed.txt \
145+ s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/staging/${GITHUB_SHA}/.deployed.txt
146+ aws s3 cp .deployed.txt \
147+ s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/staging/.deployed.txt
148+
143149 - name : Deployment summary
144150 run : |
145151 {
@@ -172,28 +178,39 @@ jobs:
172178 run : |
173179 echo "safe_repo=${GITHUB_REPOSITORY//\//-}" >> "$GITHUB_OUTPUT"
174180
175- # - name: Check prod deployment
176- # run: |
177- # DEPLOYED_URL="${{ inputs.url_staging }}/${GITHUB_SHA}/.deployed.txt"
178- # for i in {1..10}; do
179- # DEPLOYED_SHA=$(curl -fsSL "$DEPLOYED_URL" 2>/dev/null | awk '{ print $1 }' || echo "")
180- # if [ "$DEPLOYED_SHA" = "$GITHUB_SHA" ]; then
181- # exit 0
182- # else
183- # sleep 60
184- # fi
185- # done
186- #
187- # echo "Error: wrong SHA while requesting $DEPLOYED_URL"
188- # exit 1
189-
181+ - name : Wait for staging marker for this SHA
182+ run : |
183+ set -e
184+ S3="s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/staging/${GITHUB_SHA}/.deployed.txt"
185+ for i in $(seq 1 10); do
186+ if aws s3 cp "$S3" .staging.marker --only-show-errors; then
187+ grep -q '^sha=' .staging.marker && grep -q '^env=staging' .staging.marker && exit 0 || true
188+ fi
189+ sleep 10
190+ done
191+ echo "staging marker not ready for ${GITHUB_SHA}" >&2
192+ exit 1
193+
190194 - name : Sync www/ to S3
191195 run : |
192196 aws s3 sync \
193197 s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/staging/${GITHUB_SHA}/ \
194198 s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/prod/ \
195199 --delete --exact-timestamps
196200
201+ - name : Upload prod marker (.deployed.txt)
202+ run : |
203+ TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
204+ cat > .deployed.txt <<EOF
205+ sha=${GITHUB_SHA}
206+ env=prod
207+ ts=${TIMESTAMP}
208+ actor=${GITHUB_ACTOR}
209+ repo=${GITHUB_REPOSITORY}
210+ EOF
211+ aws s3 cp .deployed.txt \
212+ s3://${{ inputs.s3_bucket }}/${{ steps.vars.outputs.safe_repo }}/prod/.deployed.txt
213+
197214 - name : Deployment summary
198215 run : |
199216 {
0 commit comments