Skip to content
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

feat(ci): bundle/build worker #13

Merged
merged 4 commits into from
Aug 14, 2024
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
38 changes: 30 additions & 8 deletions .github/workflows/deploy-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@ on:
workflow_dispatch:
inputs:
dispatchNamespace:
description: 'Cloudflare Workers for Platforms dispatch namespace'
description: "Cloudflare Workers for Platforms dispatch namespace"
required: true
appId:
description: 'Worker App ID'
description: "Worker App ID"
required: true
repo:
description: 'GitHub repository name'
description: "GitHub repository name"
required: true
commit:
description: 'Git commit hash'
description: "Git commit hash"
required: true
directory:
description: 'Directory to deploy'
description: "Directory to deploy"
required: false

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest

env:
wranglerVersion: "3.68.0"
outDir: "codius-dist"

steps:
- name: ${{github.event.inputs.appId}}
run: echo run identifier ${{ github.run_id }}
Expand Down Expand Up @@ -57,14 +65,28 @@ jobs:
run: |
mv wrangler.toml wrangler.toml.orig
docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml.orig | \
jq 'del(.build, .d1_databases)' | \
jq 'del(.d1_databases)' | \
docker run -i ghcr.io/pelletier/go-toml:v2 jsontoml > wrangler.toml

- name: Extract wrangler.toml [main]
id: wrangler-main
working-directory: ${{ github.event.inputs.directory }}
run: |
wrangler_main=$(docker run -i ghcr.io/pelletier/go-toml:v2 tomljson < wrangler.toml | jq -r '.main')
echo "WRANGLER_MAIN=${wrangler_main}" >> "$GITHUB_OUTPUT"

- name: Bundle/Build Worker
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: ${{ env.wranglerVersion }}
workingDirectory: ${{ github.event.inputs.directory }}
command: deploy --dry-run --outdir=${{ env.outDir }} --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }}

- name: Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: "3.64.0"
wranglerVersion: ${{ env.wranglerVersion }}
workingDirectory: ${{ github.event.inputs.directory }}
command: deploy --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }}
command: deploy --no-bundle --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} ${{ env.outDir }}/${{ steps.wrangler-main.outputs.WRANGLER_MAIN }}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"type": "module",
"version": "0.0.1",
"scripts": {
"lint": "pnpm -r run lint",
"format": "pnpm -r run format",
"lint": "pnpm run lint-ci && pnpm -r run lint",
"format": "pnpm run format-ci && pnpm -r run format",
"smee": "pnpm --filter codius-astro smee",
"cf-typegen": "pnpm -r run cf-typegen"
"cf-typegen": "pnpm -r run cf-typegen",
"lint-ci": "prettier --check .github/workflows/**/*.yml",
"format-ci": "prettier --write .github/workflows/**/*.yml"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240729.0",
Expand Down
Loading