ci: chain browser-e2e to run only after deploy workflow succeeds via workflow_run
TaxBaik CI/CD / build-and-deploy (push) Successful in 57s
TaxBaik CI/CD / build-and-deploy (push) Successful in 57s
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
name: TaxBaik Browser E2E
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_run:
|
||||
workflows: ["TaxBaik CI/CD"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
browser-e2e:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -37,21 +39,24 @@ jobs:
|
||||
- name: Wait for deployment
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
EXPECTED_VERSION: ${{ github.event.workflow_run.head_sha }}
|
||||
run: |
|
||||
set -e
|
||||
EXPECTED_VERSION="$(git rev-parse --short HEAD)"
|
||||
for i in $(seq 1 60); do
|
||||
# Extract short commit hash (first 7 characters)
|
||||
SHORT_VERSION=$(echo "$EXPECTED_VERSION" | cut -c1-7)
|
||||
echo "Expected short version: $SHORT_VERSION"
|
||||
for i in $(seq 1 30); do
|
||||
# Suppress stderr and allow failures to handle transition/down periods cleanly
|
||||
VERSION_BODY="$(curl -fsS "http://${DEPLOY_HOST}/taxbaik/version.txt" 2>/dev/null || true)"
|
||||
BLOG_STATUS="$(curl -s -o /dev/null -w '%{http_code}' "http://${DEPLOY_HOST}/taxbaik/blog/accountant-mistakes-5" || true)"
|
||||
if echo "$VERSION_BODY" | grep -q "Version: ${EXPECTED_VERSION}" && [ "$BLOG_STATUS" = "200" ]; then
|
||||
echo "Deployment is ready for ${EXPECTED_VERSION}"
|
||||
if echo "$VERSION_BODY" | grep -q "Version: ${SHORT_VERSION}" && [ "$BLOG_STATUS" = "200" ]; then
|
||||
echo "Deployment is ready for ${SHORT_VERSION}"
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting for deployment ${EXPECTED_VERSION} (attempt $i/60); blog status=${BLOG_STATUS:-down}; version=${VERSION_BODY:-unknown}"
|
||||
sleep 10
|
||||
echo "Waiting for deployment ${SHORT_VERSION} (attempt $i/30); blog status=${BLOG_STATUS:-down}; version=${VERSION_BODY:-unknown}"
|
||||
sleep 5
|
||||
done
|
||||
echo "Deployment did not publish expected version ${EXPECTED_VERSION} in time" >&2
|
||||
echo "Deployment did not publish expected version ${SHORT_VERSION} in time" >&2
|
||||
exit 1
|
||||
|
||||
- name: Browser E2E verification
|
||||
|
||||
Reference in New Issue
Block a user