Repository navigation
Add Cloudflare CI/CD scripts and update Wrangler configuration #99
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
8 commits
Select commit
Hold shift + click to select a range
d852546
Add Cloudflare scripts and update Wrangler config
admdly 9a98ebb
Add Cloudflare Workers preview and deploy CI/CD
admdly 6df8509
Add Wrangler to development dependencies
admdly 98bfba0
Use root Wrangler config in deployment
admdly f9a2c0b
Update .github/workflows/ci-cd.yml
admdly e89d005
Update .github/workflows/cloudflare-events.yml
admdly 00b5ec6
Use Wrangler JSONC config in CI
admdly beab345
Update Cloudflare deployment workflow
admdly 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| name: CI/CD | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
|
||
| jobs: | ||
| validation: | ||
| name: Validation | ||
| runs-on: ubuntu-slim | ||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 | ||
| with: | ||
| node-version: '26' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install Dependencies | ||
| id: dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Check Formatting | ||
| if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }} | ||
| run: npm run format:check | ||
|
|
||
| - name: Astro Checks | ||
| if: ${{ !cancelled() && steps.dependencies.outcome == 'success' }} | ||
| run: npm run check | ||
|
|
||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| outputs: | ||
| wrangler-version: ${{ steps.wrangler-version.outputs.version }} | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 | ||
| with: | ||
| node-version: '26' | ||
| cache: 'npm' | ||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Read Wrangler Version | ||
| id: wrangler-version | ||
| run: | | ||
| node <<'NODE' | ||
| const fs = require('node:fs'); | ||
| const { version } = require('./node_modules/wrangler/package.json'); | ||
| fs.appendFileSync(process.env.GITHUB_OUTPUT, `version=${version}\n`); | ||
| NODE | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Validate Worker Deployment | ||
| run: npm run cf-deploy -- --dry-run --config wrangler.jsonc | ||
|
|
||
| - name: Upload Worker Build | ||
| if: github.event_name == 'push' | ||
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 | ||
| with: | ||
| name: worker-build | ||
| overwrite: true | ||
| path: dist/ | ||
| include-hidden-files: true | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| preview: | ||
| name: Cloudflare Preview | ||
| needs: [validation, build] | ||
| if: ${{ !cancelled() && github.event_name == 'push' && github.ref_type == 'branch' && github.ref != 'refs/heads/main' }} | ||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
| uses: FOSSBilling/.workflows/.github/workflows/cloudflare-workers.yml@384ecc11e315c77cf3d6abb947e859ce62b38cf5 # main | ||
| with: | ||
| operation: deploy | ||
| mode: preview | ||
| build-result: ${{ needs.build.result }} | ||
| checks-result: ${{ needs.validation.result }} | ||
| pr-comment: true | ||
| pr-base-branch: main | ||
| environment: preview | ||
| artifact-name: worker-build | ||
| artifact-path: dist/ | ||
| config-path: wrangler.jsonc | ||
| wrangler-version: ${{ needs.build.outputs.wrangler-version }} | ||
| secrets: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} | ||
|
|
||
| deploy: | ||
| name: Deploy Production | ||
| needs: [validation, build] | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| uses: FOSSBilling/.workflows/.github/workflows/cloudflare-workers.yml@384ecc11e315c77cf3d6abb947e859ce62b38cf5 # main | ||
| with: | ||
| operation: deploy | ||
| mode: production | ||
| environment: production | ||
| artifact-name: worker-build | ||
| artifact-path: dist/ | ||
| config-path: wrangler.json | ||
| wrangler-version: ${{ needs.build.outputs.wrangler-version }} | ||
| secrets: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
| name: Cloudflare Events | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ['CI/CD'] | ||
| types: [completed] | ||
| pull_request_target: | ||
| branches: [main] | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| comment: | ||
| uses: FOSSBilling/.workflows/.github/workflows/cloudflare-workers.yml@99d34fa9d93cf55d46adaa3babc715e9c76957ec # main | ||
| with: | ||
| operation: sync-pr-comment | ||
| build-workflow: ci-cd.yml | ||
| pr-base-branch: main | ||
Oops, something went wrong.
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.