Skip to content

Commit bc5531f

Browse files
committed
Added bunny workflow
1 parent 5c146f8 commit bc5531f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy to BunnyCDN Storage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: bunny-deploy
10+
cancel-in-progress: true
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Install lftp
20+
run: sudo apt-get update && sudo apt-get install -y lftp
21+
22+
- name: Upload changed files to Bunny Storage (SFTP)
23+
env:
24+
BUNNY_SFTP_HOST: storage.bunnycdn.com
25+
BUNNY_SFTP_USER: ${{ secrets.BUNNY_SFTP_USER }} # Storage Zone name (not your email)
26+
BUNNY_SFTP_PASS: ${{ secrets.BUNNY_SFTP_PASS }} # Storage Zone FTP/SFTP password
27+
LOCAL_DIR: public # change if your output lives elsewhere
28+
REMOTE_DIR: / # root of the Storage Zone
29+
run: |
30+
lftp -u "$BUNNY_SFTP_USER","$BUNNY_SFTP_PASS" sftp://"$BUNNY_SFTP_HOST" << 'EOF'
31+
set sftp:auto-confirm yes
32+
set net:max-retries 2
33+
set net:timeout 20
34+
set net:reconnect-interval-base 5
35+
open .
36+
mirror \
37+
--reverse \ # push local -> remote
38+
--verbose \ # log progress
39+
--only-newer \ # skip unchanged
40+
--continue \ # resume partial uploads
41+
--parallel=4 \ # faster
42+
--exclude-glob .git* \ # ignore junk
43+
--exclude-glob .DS_Store \
44+
"${LOCAL_DIR}" "${REMOTE_DIR}"
45+
bye
46+
EOF
47+
48+
# Optional: purge Pull Zone cache when files change
49+
- name: Purge Bunny Pull Zone cache
50+
if: ${{ github.event_name == 'push' }}
51+
env:
52+
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }} # Account API key
53+
BUNNY_PULLZONE_ID: ${{ secrets.BUNNY_PULLZONE_ID }} # Numeric ID of the Pull Zone
54+
run: |
55+
curl -sS -X POST \
56+
-H "AccessKey: $BUNNY_API_KEY" \
57+
https://api.bunny.net/pullzone/$BUNNY_PULLZONE_ID/purgeCache

0 commit comments

Comments
 (0)