Skip to content

Commit 6eb88eb

Browse files
committed
ci: temp bisect - old sync block + checkout@v4 fetch-depth:0
1 parent c5f0d57 commit 6eb88eb

1 file changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: TEST shared sync block + fetch-depth:0
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+
with:
29+
fetch-depth: 0
30+
31+
- name: Build site
32+
run: python scripts/build_site.py
33+
34+
- name: Install rclone
35+
run: curl -fsSL https://rclone.org/install.sh | sudo bash
36+
37+
- name: Configure rclone for Bunny S3
38+
env:
39+
HOMEPAGE_BUNNY_S3_ENDPOINT: ${{ secrets.HOMEPAGE_BUNNY_S3_ENDPOINT }}
40+
HOMEPAGE_BUNNY_S3_ACCESS_KEY: ${{ secrets.HOMEPAGE_BUNNY_S3_ACCESS_KEY }}
41+
HOMEPAGE_BUNNY_S3_SECRET_KEY: ${{ secrets.HOMEPAGE_BUNNY_S3_SECRET_KEY }}
42+
run: |
43+
mkdir -p ~/.config/rclone
44+
cat > ~/.config/rclone/rclone.conf <<EOF
45+
[bunny]
46+
type = s3
47+
provider = Other
48+
env_auth = false
49+
access_key_id = ${HOMEPAGE_BUNNY_S3_ACCESS_KEY}
50+
secret_access_key = ${HOMEPAGE_BUNNY_S3_SECRET_KEY}
51+
endpoint = ${HOMEPAGE_BUNNY_S3_ENDPOINT}
52+
force_path_style = true
53+
acl = private
54+
EOF
55+
56+
- name: Sync site to Bunny Storage
57+
env:
58+
HOMEPAGE_BUNNY_S3_BUCKET: ${{ secrets.HOMEPAGE_BUNNY_S3_BUCKET }}
59+
run: |
60+
ARGS=(--fast-list --checksum --transfers 16 --verbose)
61+
if [ -n "no-cache" ]; then
62+
ARGS+=(--header-upload "Cache-Control: no-cache")
63+
fi
64+
for attempt in 1 2 3 4 5; do
65+
echo "--- Sync attempt $attempt ---"
66+
if rclone sync "site/dist" "bunny:${HOMEPAGE_BUNNY_S3_BUCKET}" "${ARGS[@]}"; then
67+
echo "Sync succeeded on attempt $attempt"
68+
exit 0
69+
fi
70+
echo "Sync attempt $attempt failed; retrying in 20s..."
71+
sleep 20
72+
done
73+
echo "Sync failed after 5 attempts"
74+
exit 1
75+
76+
- name: Purge CDN cache
77+
continue-on-error: true
78+
env:
79+
HOMEPAGE_BUNNY_API_KEY: ${{ secrets.HOMEPAGE_BUNNY_API_KEY }}
80+
run: |
81+
if [ -z "$HOMEPAGE_BUNNY_API_KEY" ]; then
82+
echo "HOMEPAGE_BUNNY_API_KEY not set, skipping cache purge"
83+
exit 0
84+
fi
85+
domain="boxviewer.app"
86+
base="${{ github.event.before }}"
87+
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
88+
echo "No previous commit (force push or manual run); purging all site assets"
89+
files=$(find ./site/dist -type f | sed 's#^./site/dist/##')
90+
else
91+
echo "Detecting changed files between $base and ${{ github.sha }}"
92+
# Always purge all 4 pages when any source MD changes, plus changed site/** files
93+
md_changed=$(git diff --name-only "$base" "${{ github.sha }}" -- README.md CHANGELOG.md CREDITS.md PRIVACY.md)
94+
if [ -n "$md_changed" ]; then
95+
files="index.html changelog.html credits.html privacy.html styles.css"
96+
else
97+
files=$(git diff --name-only "$base" "${{ github.sha }}" -- site/ | sed 's#^site/##' | grep -v '^dist/' || true)
98+
files="index.html changelog.html credits.html privacy.html styles.css"
99+
fi
100+
fi
101+
if [ -z "$files" ]; then
102+
echo "Nothing to purge"
103+
exit 0
104+
fi
105+
urls=""
106+
while IFS= read -r path; do
107+
[ -n "$path" ] && urls="${urls}\"https://${domain}/${path}\","
108+
done <<< "$files"
109+
urls="[${urls%,}]"
110+
echo "Purging URLs: $urls"
111+
curl -s -X POST "https://api.bunny.net/purge" \
112+
-H "AccessKey: ${HOMEPAGE_BUNNY_API_KEY}" \
113+
-H "Content-Type: application/json" \
114+
-d "{\"Urls\":${urls}}"
115+
116+
117+

0 commit comments

Comments
 (0)