-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 2.42 KB
/
deploy.yml
File metadata and controls
71 lines (58 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Deploy Theme
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SITE_URL: https://drunk.support
steps:
- uses: actions/checkout@v4
- name: Validate newspaper UI markers
run: php tests/theme-design-static.php
- name: Write deploy marker
run: |
printf '%s\n' "$GITHUB_SHA" > DEPLOY_SHA
{
printf 'repo=%s\n' "$GITHUB_REPOSITORY"
printf 'sha=%s\n' "$GITHUB_SHA"
printf 'run_id=%s\n' "$GITHUB_RUN_ID"
printf 'run_attempt=%s\n' "$GITHUB_RUN_ATTEMPT"
printf 'deployed_at=%s\n' "$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
} > DEPLOY_INFO
- name: Deploy via rsync
uses: burnett01/rsync-deployments@6.0.0
with:
switches: -avz --delete --exclude='.git' --exclude='.github' --exclude='node_modules'
path: ./
remote_path: ${{ secrets.CLOUDWAYS_PATH }}
remote_host: ${{ secrets.CLOUDWAYS_HOST }}
remote_user: ${{ secrets.CLOUDWAYS_USER }}
remote_key: ${{ secrets.CLOUDWAYS_SSH_KEY }}
- name: Verify deployed commit
run: |
set -euo pipefail
marker_url="${SITE_URL%/}/wp-content/themes/minimalcode/DEPLOY_SHA?check=${GITHUB_SHA}"
for attempt in 1 2 3 4 5; do
deployed_sha="$(curl -fsSL -H 'Cache-Control: no-cache' "$marker_url" || true)"
if [ "$deployed_sha" = "$GITHUB_SHA" ]; then
echo "Production is serving commit $GITHUB_SHA"
exit 0
fi
echo "Attempt ${attempt}: expected ${GITHUB_SHA}, got '${deployed_sha:-<empty>}'"
sleep 3
done
echo "Production did not serve the deployed commit marker." >&2
exit 1
- name: Smoke test live theme
run: |
set -euo pipefail
homepage="$(curl -fsSL -H 'Cache-Control: no-cache' "${SITE_URL%/}/?deploy-check=${GITHUB_SHA}")"
custom_css="$(curl -fsSL -H 'Cache-Control: no-cache' "${SITE_URL%/}/wp-content/themes/minimalcode/assets/css/custom.css?deploy-check=${GITHUB_SHA}")"
grep -q 'wp-content/themes/minimalcode/assets/css/custom.css' <<< "$homepage"
grep -q 'class="ticker"' <<< "$homepage"
grep -q 'class="masthead wrap"' <<< "$homepage"
grep -q -- '--paper' <<< "$custom_css"
grep -q '.entry-hash' <<< "$custom_css"