Skip to content

Commit 44ae0ef

Browse files
authored
Add GitHub Actions workflow for Cloudflare R2 sync
This workflow automates the synchronization of files to Cloudflare R2 upon pushes to the main branch or manually via workflow dispatch.
1 parent de34f1d commit 44ae0ef

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/r2-sync.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Sync to Cloudflare R2
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync:
10+
runs-on: ubuntu-latest
11+
env:
12+
AWS_REGION: auto
13+
AWS_S3_FORCE_PATH_STYLE: "true"
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Configure credentials
19+
run: |
20+
echo "AWS_ACCESS_KEY_ID=${{ secrets.MIRROR_R2_ACCESS_KEY_ID }}" >> $GITHUB_ENV
21+
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.MIRROR_R2_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
22+
23+
- name: Sync to Cloudflare R2
24+
run: |
25+
REPO_NAME="${{ github.event.repository.name }}"
26+
ENDPOINT="https://${{ vars.CF_ACCOUNT_ID }}.r2.cloudflarestorage.com"
27+
DEST="s3://${{ vars.MIRROR_R2_BUCKET }}/${REPO_NAME}"
28+
29+
aws s3 sync . "$DEST" \
30+
--endpoint-url "$ENDPOINT" \
31+
--follow-symlinks \
32+
--delete \
33+
--exact-timestamps \
34+
--exclude "*" \
35+
--include "**/*" \
36+
--exclude ".*" \
37+
--exclude "**/README.md" \
38+
--exclude "**/egg-*.json" \
39+
--exclude "**/meta-*.json"

0 commit comments

Comments
 (0)