refactor: AWS CLI → wrangler R2로 배포 속도 개선
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
# Gitea Actions 워크플로우 예시
|
name: Deploy to R2
|
||||||
# 고객 저장소에서 사용할 템플릿
|
|
||||||
|
|
||||||
name: Deploy to CF Multisite
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -19,44 +16,36 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
|
||||||
# Hugo 사이트인 경우 (선택사항)
|
- name: Install wrangler
|
||||||
# - name: Setup Hugo
|
run: npm install -g wrangler
|
||||||
# run: |
|
|
||||||
# wget -qO- https://github.com/gohugoio/hugo/releases/download/v0.139.0/hugo_extended_0.139.0_linux-amd64.tar.gz | tar xz
|
|
||||||
# sudo mv hugo /usr/local/bin/
|
|
||||||
|
|
||||||
# - name: Build Hugo
|
|
||||||
# run: hugo --minify
|
|
||||||
|
|
||||||
- name: Install AWS CLI
|
|
||||||
run: |
|
|
||||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
|
||||||
unzip -q awscliv2.zip
|
|
||||||
sudo ./aws/install
|
|
||||||
|
|
||||||
- name: Upload to R2
|
- name: Upload to R2
|
||||||
env:
|
env:
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY }}
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
||||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_KEY }}
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
||||||
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
|
|
||||||
R2_BUCKET: multisite-bucket
|
R2_BUCKET: multisite-bucket
|
||||||
# 저장소 이름을 고객 ID로 사용 (또는 별도 설정)
|
CUSTOMER_ID: ${{ github.repository_name }}
|
||||||
CUSTOMER_ID: ${{ github.repository_owner }}
|
|
||||||
run: |
|
run: |
|
||||||
# 정적 파일 디렉토리 (Hugo: public, 일반: . 또는 dist)
|
|
||||||
SOURCE_DIR="."
|
SOURCE_DIR="."
|
||||||
|
|
||||||
# Hugo 빌드 결과가 있으면 그것 사용
|
|
||||||
if [ -d "public" ]; then
|
if [ -d "public" ]; then
|
||||||
SOURCE_DIR="public"
|
SOURCE_DIR="public"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
aws s3 sync "$SOURCE_DIR" "s3://${R2_BUCKET}/sites/${CUSTOMER_ID}/" \
|
echo "Deploying $CUSTOMER_ID from $SOURCE_DIR"
|
||||||
--endpoint-url "$R2_ENDPOINT" \
|
|
||||||
--exclude ".git/*" \
|
|
||||||
--exclude ".gitea/*" \
|
|
||||||
--exclude "*.md" \
|
|
||||||
--exclude "README*" \
|
|
||||||
--delete
|
|
||||||
|
|
||||||
echo "Deployed to: https://${CUSTOMER_ID}.yoursite.com"
|
find "$SOURCE_DIR" -type f \
|
||||||
|
-not -path '*/.git/*' \
|
||||||
|
-not -path '*/.gitea/*' \
|
||||||
|
-not -name '*.md' \
|
||||||
|
-not -name 'README*' \
|
||||||
|
-not -name 'package*.json' \
|
||||||
|
-not -name 'wrangler.toml' \
|
||||||
|
-not -name '.rebuild' \
|
||||||
|
-not -name '.gitignore' \
|
||||||
|
-not -name 'LICENSE' | while read file; do
|
||||||
|
key="sites/${CUSTOMER_ID}/${file#$SOURCE_DIR/}"
|
||||||
|
echo " uploading: $key"
|
||||||
|
wrangler r2 object put "${R2_BUCKET}/${key}" --file="$file" --content-type="$(file -b --mime-type $file)"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Deployed to: https://${CUSTOMER_ID}.actions.it.com"
|
||||||
|
|||||||
Reference in New Issue
Block a user