Skip to content

Commit

Permalink
ci: upload config to cloudflare (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxtrotSierra6829 authored Oct 30, 2024
1 parent 8ab28fc commit 82739cc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
- name: Build config
run: |
npm run build -- pr-${{ github.event.number }}
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_BUCKET_PASSWORD: ${{ secrets.CLOUDFLARE_BUCKET_PASSWORD }}
CDN_BUCKET_DESTINATION: installer/config
run: ./scripts/cdn-cf.sh ./dist $CDN_BUCKET_DESTINATION
- name: Upload to Bunny CDN
env:
BUNNY_BUCKET_PASSWORD: ${{ secrets.BUNNY_BUCKET_PASSWORD }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
- name: Build config
run: |
npm run build -- production
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_BUCKET_PASSWORD: ${{ secrets.CLOUDFLARE_BUCKET_PASSWORD }}
CDN_BUCKET_DESTINATION: installer/config
run: ./scripts/cdn-cf.sh ./dist $CDN_BUCKET_DESTINATION
- name: Upload to Bunny CDN
env:
BUNNY_BUCKET_PASSWORD: ${{ secrets.BUNNY_BUCKET_PASSWORD }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
- name: Build config
run: |
npm run build -- staging
- name: Upload to CloudFlare CDN
env:
CLOUDFLARE_BUCKET_PASSWORD: ${{ secrets.CLOUDFLARE_BUCKET_PASSWORD }}
CDN_BUCKET_DESTINATION: installer/config
run: ./scripts/cdn-cf.sh ./dist $CDN_BUCKET_DESTINATION
- name: Upload to Bunny CDN
env:
BUNNY_BUCKET_PASSWORD: ${{ secrets.BUNNY_BUCKET_PASSWORD }}
Expand Down
25 changes: 25 additions & 0 deletions scripts/cdn-cf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

CDN_URL="flybywirecdn.com"
CDN_PURGE_LINK="https://flybywirecdn.com/purgeCache?url=http://flybywirecdn.com"
FILES=${1}
CDN_DIR=${2:-"installer/config/test"}

echo "Syncing files from: ${FILES}/*"
echo "Syncing to: ${CDN_DIR}"

for FILE in "${FILES}"/*; do
DEST="$CDN_URL/$CDN_DIR/$(basename -- "$FILE")"
echo "Syncing file: $FILE"
echo "Destination: $DEST"
curl -X PUT -H "X-FBW-Access-Key: $CLOUDFLARE_BUCKET_PASSWORD" -T "$FILE" "$DEST"
done

# Purge after all uploads that the files are somewhat in sync
echo "Purging cache"
for FILE in "${FILES}"/*; do
DEST="$CDN_PURGE_LINK/$CDN_DIR/$(basename -- "$FILE")"
echo "Purging cache for file: $FILE"
echo "Purge URL: $DEST"
curl -X POST -H "X-FBW-Access-Key: $CLOUDFLARE_BUCKET_PASSWORD" -H "Content-Length: 0" "$DEST"
done

0 comments on commit 82739cc

Please sign in to comment.