correct logo #6
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 to Cloudflare R2 | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| concurrency: | |
| group: "deploy" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build Site | |
| run: npm run build | |
| - name: Install Wrangler | |
| run: npm install -g wrangler | |
| - name: Deploy SPA to R2 | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_KEY }} | |
| run: | | |
| # Upload all built files to R2 bucket | |
| for file in $(find dist -type f); do | |
| # Get the path relative to dist/ | |
| key="${file#dist/}" | |
| # Determine content type | |
| content_type="application/octet-stream" | |
| case "$file" in | |
| *.html) content_type="text/html; charset=utf-8" ;; | |
| *.css) content_type="text/css; charset=utf-8" ;; | |
| *.js) content_type="application/javascript; charset=utf-8" ;; | |
| *.json) content_type="application/json" ;; | |
| *.svg) content_type="image/svg+xml" ;; | |
| *.png) content_type="image/png" ;; | |
| *.ico) content_type="image/x-icon" ;; | |
| esac | |
| echo "Uploading $key with content-type: $content_type" | |
| wrangler r2 object put "mirror/$key" --file="$file" --content-type="$content_type" | |
| done | |
| - name: Deploy Worker | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_KEY }} | |
| run: | | |
| cd worker | |
| wrangler deploy |