diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 7eee190..a88cd5e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,7 +1,4 @@ -# Gitea Actions 워크플로우 예시 -# 고객 저장소에서 사용할 템플릿 - -name: Deploy to CF Multisite +name: Deploy to R2 on: push: @@ -19,44 +16,36 @@ jobs: with: node-version: '20' - # Hugo 사이트인 경우 (선택사항) - # - name: Setup Hugo - # 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: Install wrangler + run: npm install -g wrangler - name: Upload to R2 env: - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_KEY }} - R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} R2_BUCKET: multisite-bucket - # 저장소 이름을 고객 ID로 사용 (또는 별도 설정) - CUSTOMER_ID: ${{ github.repository_owner }} + CUSTOMER_ID: ${{ github.repository_name }} run: | - # 정적 파일 디렉토리 (Hugo: public, 일반: . 또는 dist) SOURCE_DIR="." - - # Hugo 빌드 결과가 있으면 그것 사용 if [ -d "public" ]; then SOURCE_DIR="public" fi - aws s3 sync "$SOURCE_DIR" "s3://${R2_BUCKET}/sites/${CUSTOMER_ID}/" \ - --endpoint-url "$R2_ENDPOINT" \ - --exclude ".git/*" \ - --exclude ".gitea/*" \ - --exclude "*.md" \ - --exclude "README*" \ - --delete + echo "Deploying $CUSTOMER_ID from $SOURCE_DIR" - 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"