-
Notifications
You must be signed in to change notification settings - Fork 0
🚀 Implement multi-environment deployment and D1 configuration, fixes #13 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
99c3126
🚀 Implement multi-environment deployment and D1 configuration
synmux afed3d3
📝 (README.md): reformat text and update section headings
synmux 0c0a2a8
📝 Simplify database section header in README
synmux 35ca740
Fix deploy:staging
synmux 55ca11f
Use env vars for db:migrate:*
synmux 232f314
Remove typecast, it's only a warning
synmux 274d20e
Staging should build staging, duh
synmux 1b055f4
Remove commented out config
synmux 1668590
expand dev wrangler.jsonc
synmux 33a5add
Merge branch 'staging' into feature/aff-1-fix-up-staging-environment
synmux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| name: deploy | ||
| on: | ||
| push: | ||
| branches: [staging, production] | ||
| pull_request: | ||
| branches: [staging] | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| deployments: write | ||
| concurrency: | ||
| group: deploy-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| deploy-staging: | ||
| if: github.ref == 'refs/heads/staging' && github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| environment: staging | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||
| - name: bun | ||
| uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 | ||
| with: | ||
| bun-version: 1.3.9 | ||
| - name: install | ||
| run: bun install | ||
| - name: migrate | ||
| run: bun run db:migrate:staging | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| - name: build | ||
| run: bun run build:staging | ||
| - name: upload version | ||
| run: bun run wrangler versions upload | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
|
|
||
| deploy-production: | ||
| if: github.ref == 'refs/heads/production' && github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| environment: production | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||
| - name: bun | ||
| uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 | ||
| with: | ||
| bun-version: 1.3.9 | ||
| - name: install | ||
| run: bun install | ||
| - name: migrate | ||
| run: bun run db:migrate:prod | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| - name: build | ||
| run: bun run build | ||
| - name: deploy | ||
| run: bun run wrangler deploy | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
|
|
||
| preview: | ||
| if: github.event_name == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | ||
| - name: bun | ||
| uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 | ||
| with: | ||
| bun-version: 1.3.9 | ||
| - name: install | ||
| run: bun install | ||
| - name: build | ||
| run: bun run build:staging | ||
| - name: upload version | ||
| id: upload | ||
| run: | | ||
| OUTPUT=$(bun run wrangler versions upload 2>&1) | ||
| echo "$OUTPUT" | ||
| VERSION_ID=$(echo "$OUTPUT" | grep -oP 'Worker Version ID:\s+\K[a-f0-9-]+') | ||
| echo "version_id=$VERSION_ID" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| - name: comment preview url | ||
| if: steps.upload.outputs.version_id != '' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| VERSION_ID: ${{ steps.upload.outputs.version_id }} | ||
| run: | | ||
| gh pr comment "$PR_NUMBER" --body "Preview version uploaded to **affirm** worker (staging D1). | ||
|
|
||
| **Version ID:** \`$VERSION_ID\` | ||
|
|
||
| Preview URL available in the [Cloudflare dashboard](https://dash.cloudflare.com/) under Workers > affirm > Versions." | ||
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.