Added bunny workflow

This commit is contained in:
Kev Quirk
2025-08-11 15:11:54 +01:00
parent 5c146f8fb9
commit bc5531ff5a
@@ -0,0 +1,57 @@
name: Deploy to BunnyCDN Storage
on:
push:
branches: [ main ]
workflow_dispatch:
concurrency:
group: bunny-deploy
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install lftp
run: sudo apt-get update && sudo apt-get install -y lftp
- name: Upload changed files to Bunny Storage (SFTP)
env:
BUNNY_SFTP_HOST: storage.bunnycdn.com
BUNNY_SFTP_USER: ${{ secrets.BUNNY_SFTP_USER }} # Storage Zone name (not your email)
BUNNY_SFTP_PASS: ${{ secrets.BUNNY_SFTP_PASS }} # Storage Zone FTP/SFTP password
LOCAL_DIR: public # change if your output lives elsewhere
REMOTE_DIR: / # root of the Storage Zone
run: |
lftp -u "$BUNNY_SFTP_USER","$BUNNY_SFTP_PASS" sftp://"$BUNNY_SFTP_HOST" << 'EOF'
set sftp:auto-confirm yes
set net:max-retries 2
set net:timeout 20
set net:reconnect-interval-base 5
open .
mirror \
--reverse \ # push local -> remote
--verbose \ # log progress
--only-newer \ # skip unchanged
--continue \ # resume partial uploads
--parallel=4 \ # faster
--exclude-glob .git* \ # ignore junk
--exclude-glob .DS_Store \
"${LOCAL_DIR}" "${REMOTE_DIR}"
bye
EOF
# Optional: purge Pull Zone cache when files change
- name: Purge Bunny Pull Zone cache
if: ${{ github.event_name == 'push' }}
env:
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }} # Account API key
BUNNY_PULLZONE_ID: ${{ secrets.BUNNY_PULLZONE_ID }} # Numeric ID of the Pull Zone
run: |
curl -sS -X POST \
-H "AccessKey: $BUNNY_API_KEY" \
https://api.bunny.net/pullzone/$BUNNY_PULLZONE_ID/purgeCache