generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
361 additions
and
7,278 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,33 @@ | ||
name: Formatting Check | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
format-check: | ||
name: Check for formatting errors | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.10.0 | ||
|
||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v2 | ||
|
||
- name: Install toolchain | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Eslint | ||
run: bun run eslint --fix-dry-run | ||
|
||
- name: Cspell | ||
run: bun run format:cspell | ||
|
||
- name: Prettier | ||
run: bun run prettier --check . |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,29 +1,38 @@ | ||
name: Deploy Worker | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Update Configuration and Build"] | ||
types: | ||
- completed | ||
|
||
env: | ||
APP_ID: ${{ secrets.APP_ID }} | ||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
jobs: | ||
deploy-to-cloudflare: | ||
runs-on: ubuntu-latest | ||
name: Automatic Cloudflare Deploy | ||
environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }} | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.10.0" | ||
|
||
- name: Enable corepack | ||
run: corepack enable | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v2 | ||
|
||
- name: Update wrangler.toml Name Field | ||
id: update_toml | ||
run: | | ||
branch_name=$(echo '${{ github.event.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g') | ||
branch_name=$(echo '${{ github.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g') | ||
# Extract base name from wrangler.toml | ||
base_name=$(grep '^name = ' wrangler.toml | sed 's/^name = "\(.*\)"$/\1/') | ||
# Concatenate branch name with base name | ||
|
@@ -33,26 +42,66 @@ jobs: | |
# Update the wrangler.toml file | ||
sed -i "s/^name = .*/name = \"$new_name\"/" wrangler.toml | ||
echo "Updated wrangler.toml name to: $new_name" | ||
echo "::set-output name=workerName::$new_name" | ||
- name: Deploy with Wrangler | ||
id: wrangler_deploy | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
wranglerVersion: "3.80.4" | ||
wranglerVersion: "3.87.0" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
secrets: | | ||
SUPABASE_URL | ||
SUPABASE_KEY | ||
${{ secrets.KERNEL_PUBLIC_KEY && secrets.KERNEL_PUBLIC_KEY != '' && 'KERNEL_PUBLIC_KEY' || '' }} | ||
CLOUDFLARE_ACCOUNT_ID | ||
CLOUDFLARE_WORKER_NAME | ||
CLOUDFLARE_API_TOKEN | ||
env: | ||
SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | ||
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} | ||
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_WORKER_NAME: ${{ steps.update_toml.outputs.workerName }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
|
||
- name: Update manifest.json worker url | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json'); | ||
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); | ||
manifest["homepage_url"] = "${{ steps.wrangler_deploy.outputs.deployment-url }}"; | ||
const updatedManifest = JSON.stringify(manifest, null, 2); | ||
fs.writeFileSync(manifestPath, updatedManifest); | ||
console.log('Updated manifest:', updatedManifest); | ||
- name: Get GitHub App token | ||
if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ env.APP_ID }} | ||
private-key: ${{ env.APP_PRIVATE_KEY }} | ||
|
||
- name: Format manifest.json using Prettier | ||
shell: bash | ||
run: | | ||
bun add -DE prettier | ||
bun prettier --write . | ||
- name: Commit file | ||
uses: swinton/[email protected] | ||
env: | ||
GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} | ||
with: | ||
files: | | ||
manifest.json | ||
commit-message: "chore: [skip ci] update manifest.json url" | ||
ref: ${{ github.ref }} | ||
|
||
- name: Write Deployment URL to Summary | ||
run: | | ||
|
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit "$1" | ||
commitlint --edit "$1" |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged | ||
lint-staged |
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.