Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/ci-cd.yml
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 }}
37 changes: 0 additions & 37 deletions .github/workflows/ci.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/cloudflare-events.yml
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 thread
admdly marked this conversation as resolved.
Resolved
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
Loading
Loading