Skip to content

Commit

Permalink
Merge pull request #111 from gentlementlegen/feat/url
Browse files Browse the repository at this point in the history
feat: deploy url
  • Loading branch information
gentlementlegen authored Dec 18, 2024
2 parents 393a601 + 516d946 commit b8a6dfc
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update-configuration.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Update Manifest and Commit Changes
name: "Update Configuration and Build"

on:
workflow_dispatch:
push:

jobs:
update-manifest:
name: "Update Manifest and Commit Changes"
name: "Update Configuration & Build"
runs-on: ubuntu-latest
permissions: write-all

Expand Down
57 changes: 52 additions & 5 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,31 +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:
runs-on: ubuntu-latest
name: 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
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
Expand Down Expand Up @@ -54,6 +61,46 @@ jobs:
BOT_USER_ID: ${{ secrets.BOT_USER_ID }}
KERNEL_PUBLIC_KEY: ${{ secrets.KERNEL_PUBLIC_KEY }}

- 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: |
echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
"dependencies": {
"@octokit/graphql-schema": "15.25.0",
"@octokit/plugin-rest-endpoint-methods": "^13.2.6",
"@octokit/types": "^13.6.1",
"@octokit/types": "^13.6.2",
"@sinclair/typebox": "0.34.3",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-os/plugin-sdk": "^1.1.0",
"@ubiquity-os/plugin-sdk": "^1.1.1",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"dotenv": "^16.4.4",
"hono": "^4.6.12",
"dotenv": "^16.4.7",
"hono": "^4.6.14",
"ms": "^2.1.3"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@cspell/dict-node": "^5.0.5",
"@cspell/dict-software-terms": "^4.1.15",
"@cspell/dict-typescript": "^3.1.2",
"@cspell/dict-software-terms": "^4.1.20",
"@cspell/dict-typescript": "^3.1.11",
"@eslint/js": "9.14.0",
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
Expand All @@ -68,9 +68,9 @@
"ts-jest": "29.1.5",
"ts-node": "^10.9.2",
"tsx": "4.15.6",
"typescript": "5.6.2",
"typescript-eslint": "8.14.0",
"wrangler": "^3.87.0"
"typescript": "5.5.4",
"typescript-eslint": "^8.18.1",
"wrangler": "^3.97.0"
},
"lint-staged": {
"*.ts": [
Expand Down

0 comments on commit b8a6dfc

Please sign in to comment.