After publishing, the job asks the live site for its version and fails if it is not the commit it published. The test ran only when the repository variable SITE_URL was set, and it was not, so a job that published to a directory nothing serves passed. The address defaults to https://pplus.scient.ing; SITE_URL still overrides it.
This commit is contained in:
3 files changed
+7
-5
No files matched your search
@@ -14,7 +14,7 @@
|
||||
#
|
||||
# Repository -> Settings -> Actions -> Variables (all optional):
|
||||
# SITE_SLUG the directory under /srv/www (defaults to pplus, the directory docs/Caddyfile serves)
|
||||
# SITE_URL e.g. https://pplus.scient.ing, turns on the smoke test
|
||||
# SITE_URL where the site is served, for the smoke test (defaults to https://pplus.scient.ing)
|
||||
name: Build, test, deploy
|
||||
on:
|
||||
push:
|
||||
@@ -98,15 +98,16 @@ jobs:
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: scripts/deploy.sh "$SLUG"
|
||||
|
||||
# the live site must now say it is this commit: a job that publishes where nothing is served fails here
|
||||
- name: Smoke test
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.SITE_URL != ''
|
||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
|
||||
shell: bash
|
||||
env:
|
||||
SITE_URL: ${{ vars.SITE_URL }}
|
||||
SITE_URL: ${{ vars.SITE_URL || 'https://pplus.scient.ing' }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
sleep 2
|
||||
live=$(curl -fsS "$SITE_URL/VERSION")
|
||||
live=$(curl -fsS --retry 3 --retry-delay 2 "$SITE_URL/VERSION")
|
||||
case "$live" in
|
||||
"${GITHUB_SHA:0:12}"*) echo "live site is at $live" ;;
|
||||
*) echo "live site reports '$live', expected ${GITHUB_SHA:0:12}" >&2; exit 1 ;;
|
||||
|
||||
Reference in new issue
Block a user