-
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 2.69 KB
/
Copy pathdeploy-share.yml
File metadata and controls
85 lines (77 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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}}"