Skip to content

Commit 5a915e9

Browse files
committed
ci: temp bisect - old deploy-site but checkout@v4
1 parent 28b6763 commit 5a915e9

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: TEST old deploy-site but checkout@v4
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'README.md'
9+
- 'CHANGELOG.md'
10+
- 'CREDITS.md'
11+
- 'PRIVACY.md'
12+
- 'site/**'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: bunny-site-deploy
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build-and-deploy:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout source code
27+
uses: actions/checkout@v4
28+
29+
- name: Build site
30+
run: python scripts/build_site.py
31+
32+
- name: Install rclone
33+
run: curl -fsSL https://rclone.org/install.sh | sudo bash
34+
35+
- name: Configure rclone for Bunny S3
36+
env:
37+
HOMEPAGE_BUNNY_S3_ENDPOINT: ${{ secrets.HOMEPAGE_BUNNY_S3_ENDPOINT }}
38+
HOMEPAGE_BUNNY_S3_ACCESS_KEY: ${{ secrets.HOMEPAGE_BUNNY_S3_ACCESS_KEY }}
39+
HOMEPAGE_BUNNY_S3_SECRET_KEY: ${{ secrets.HOMEPAGE_BUNNY_S3_SECRET_KEY }}
40+
run: |
41+
mkdir -p ~/.config/rclone
42+
cat > ~/.config/rclone/rclone.conf <<EOF
43+
[bunny]
44+
type = s3
45+
provider = Other
46+
env_auth = false
47+
access_key_id = ${HOMEPAGE_BUNNY_S3_ACCESS_KEY}
48+
secret_access_key = ${HOMEPAGE_BUNNY_S3_SECRET_KEY}
49+
endpoint = ${HOMEPAGE_BUNNY_S3_ENDPOINT}
50+
force_path_style = true
51+
acl = private
52+
EOF
53+
54+
- name: Sync site to Bunny Storage
55+
env:
56+
HOMEPAGE_BUNNY_S3_BUCKET: ${{ secrets.HOMEPAGE_BUNNY_S3_BUCKET }}
57+
run: |
58+
rclone sync ./site/dist "bunny:${HOMEPAGE_BUNNY_S3_BUCKET}" \
59+
--fast-list --checksum --transfers 16 --verbose \
60+
--header-upload "Cache-Control: no-cache"
61+
62+
- name: Purge CDN cache
63+
continue-on-error: true
64+
env:
65+
HOMEPAGE_BUNNY_API_KEY: ${{ secrets.HOMEPAGE_BUNNY_API_KEY }}
66+
run: |
67+
if [ -z "$HOMEPAGE_BUNNY_API_KEY" ]; then
68+
echo "HOMEPAGE_BUNNY_API_KEY not set, skipping cache purge"
69+
exit 0
70+
fi
71+
domain="boxviewer.app"
72+
base="${{ github.event.before }}"
73+
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
74+
echo "No previous commit (force push or manual run); purging all site assets"
75+
files=$(find ./site/dist -type f | sed 's#^./site/dist/##')
76+
else
77+
echo "Detecting changed files between $base and ${{ github.sha }}"
78+
# Always purge all 4 pages when any source MD changes, plus changed site/** files
79+
md_changed=$(git diff --name-only "$base" "${{ github.sha }}" -- README.md CHANGELOG.md CREDITS.md PRIVACY.md)
80+
if [ -n "$md_changed" ]; then
81+
files="index.html changelog.html credits.html privacy.html styles.css"
82+
else
83+
files=$(git diff --name-only "$base" "${{ github.sha }}" -- site/ | sed 's#^site/##' | grep -v '^dist/' || true)
84+
files="index.html changelog.html credits.html privacy.html styles.css"
85+
fi
86+
fi
87+
if [ -z "$files" ]; then
88+
echo "Nothing to purge"
89+
exit 0
90+
fi
91+
urls=""
92+
while IFS= read -r path; do
93+
[ -n "$path" ] && urls="${urls}\"https://${domain}/${path}\","
94+
done <<< "$files"
95+
urls="[${urls%,}]"
96+
echo "Purging URLs: $urls"
97+
curl -s -X POST "https://api.bunny.net/purge" \
98+
-H "AccessKey: ${HOMEPAGE_BUNNY_API_KEY}" \
99+
-H "Content-Type: application/json" \
100+
-d "{\"Urls\":${urls}}"
101+

0 commit comments

Comments
 (0)