name: Reusable Rust Worker Deploy
on:
workflow_call:
inputs:
worker-name:
description: 'Name of the worker (e.g., passwords, authenticator)'
required: true
type: string
worker-path:
description: 'Path to the worker directory (e.g., apps/passwords/worker, services/authentication)'
required: true
type: string
workspace-path:
description: 'Path to the Cargo workspace root (defaults to repository root ".")'
required: false
type: string
default: '.'
secrets:
CLOUDFLARE_API_TOKEN:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Workers
defaults:
run:
working-directory: ./${{ inputs.worker-path }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ inputs.workspace-path }}
shared-key: ${{ inputs.worker-name }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install wrangler
run: npm install -g wrangler
- name: Deploy Worker
run: wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
name: Reusable Rust Worker Deploy
on:
workflow_call:
inputs:
worker-name:
description: 'Name of the worker (e.g., passwords, authenticator)'
required: true
type: string
worker-path:
description: 'Path to the worker directory (e.g., apps/passwords/worker, services/authentication)'
required: true
type: string
workspace-path:
description: 'Path to the Cargo workspace root (defaults to repository root ".")'
required: false
type: string
default: '.'
secrets:
CLOUDFLARE_API_TOKEN:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Deploy to Cloudflare Workers
defaults:
run:
working-directory: ./${{ inputs.worker-path }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ inputs.workspace-path }}
shared-key: ${{ inputs.worker-name }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install wrangler
run: npm install -g wrangler
- name: Deploy Worker
run: wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}