refactor: clean up architecture and add error page #12
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 Website | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Build | |
| run: npm run build | |
| - name: Install Wrangler | |
| run: npm install -g wrangler | |
| - name: Run D1 Migrations | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| run: | | |
| for migration in migrations/*.sql; do | |
| if [ -f "$migration" ]; then | |
| echo "::group::Migration: $migration" | |
| if wrangler d1 execute openboot --remote --file="$migration" 2>&1; then | |
| echo "Migration applied successfully" | |
| else | |
| echo "Migration skipped (already applied or error)" | |
| fi | |
| echo "::endgroup::" | |
| fi | |
| done | |
| - name: Deploy | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |