Change injected project URL on vanilla page #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy share page to bunny.net | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'share/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: bunny-deploy | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v7 | |
| - name: Install rclone | |
| run: curl -fsSL https://rclone.org/install.sh | sudo bash | |
| - name: Configure rclone for Bunny S3 | |
| env: | |
| BUNNY_S3_ENDPOINT: ${{ secrets.BUNNY_S3_ENDPOINT }} | |
| BUNNY_S3_ACCESS_KEY: ${{ secrets.BUNNY_S3_ACCESS_KEY }} | |
| BUNNY_S3_SECRET_KEY: ${{ secrets.BUNNY_S3_SECRET_KEY }} | |
| run: | | |
| mkdir -p ~/.config/rclone | |
| cat > ~/.config/rclone/rclone.conf <<EOF | |
| [bunny] | |
| type = s3 | |
| provider = Other | |
| env_auth = false | |
| access_key_id = ${BUNNY_S3_ACCESS_KEY} | |
| secret_access_key = ${BUNNY_S3_SECRET_KEY} | |
| endpoint = ${BUNNY_S3_ENDPOINT} | |
| force_path_style = true | |
| acl = private | |
| EOF | |
| - name: Sync share assets to Bunny Storage | |
| env: | |
| BUNNY_S3_BUCKET: ${{ secrets.BUNNY_S3_BUCKET }} | |
| run: | | |
| rclone sync ./share "bunny:${BUNNY_S3_BUCKET}" \ | |
| --fast-list --checksum --transfers 16 --verbose | |
| - name: Purge CDN cache for changed files | |
| continue-on-error: true | |
| env: | |
| BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }} | |
| run: | | |
| if [ -z "$BUNNY_API_KEY" ]; then | |
| echo "BUNNY_API_KEY not set, skipping cache purge" | |
| exit 0 | |
| fi | |
| domain="share.boxviewer.app" | |
| base="${{ github.event.before }}" | |
| if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then | |
| echo "No previous commit available (force push or manual run); purging all share assets" | |
| files=$(find ./share -type f | sed 's#^./share/##') | |
| else | |
| echo "Detecting changed files between $base and ${{ github.sha }}" | |
| files=$(git diff --name-only "$base" "${{ github.sha }}" -- share/ | sed 's#^share/##') | |
| fi | |
| if [ -z "$files" ]; then | |
| echo "No web files changed, nothing to purge" | |
| exit 0 | |
| fi | |
| urls="" | |
| while IFS= read -r path; do | |
| [ -n "$path" ] && urls="${urls}\"https://${domain}/${path}\"," | |
| done <<< "$files" | |
| urls="[${urls%,}]" | |
| echo "Purging URLs: $urls" | |
| curl -s -X POST "https://api.bunny.net/purge" \ | |
| -H "AccessKey: ${BUNNY_API_KEY}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"Urls\":${urls}}" |