From bc5531ff5a1ab4268f2674c009dd19ed5de4059d Mon Sep 17 00:00:00 2001 From: Kev Quirk Date: Mon, 11 Aug 2025 15:11:54 +0100 Subject: [PATCH] Added bunny workflow --- .github/workflows/bunny-storage-deploy.yml | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/bunny-storage-deploy.yml diff --git a/.github/workflows/bunny-storage-deploy.yml b/.github/workflows/bunny-storage-deploy.yml new file mode 100644 index 0000000..a647ef1 --- /dev/null +++ b/.github/workflows/bunny-storage-deploy.yml @@ -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