From e78898ffd8baac30c7d194cae20d3cab55f018e6 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 19:37:17 +0900 Subject: [PATCH 01/25] chore: updated deployment workflow --- .github/workflows/update-configuration.yml | 10 +++++----- .github/workflows/worker-deploy.yml | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-configuration.yml b/.github/workflows/update-configuration.yml index cbd9448..bcf5f60 100644 --- a/.github/workflows/update-configuration.yml +++ b/.github/workflows/update-configuration.yml @@ -1,4 +1,4 @@ -name: Update Manifest and Commit Changes +name: "Update Configuration and Build" on: workflow_dispatch: @@ -6,16 +6,16 @@ on: jobs: update-manifest: - name: "Update Manifest and Commit Changes" + name: "Update Configuration & Build" runs-on: ubuntu-latest permissions: write-all steps: - - name: Update Manifest and Commit Changes - uses: ubiquity-os/action-deploy-plugin@main + - uses: ubiquity-os/action-deploy-plugin@main with: treatAsEsm: false sourcemap: false pluginEntry: ${{ github.workspace }}/src/main.ts env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_ID: ${{ secrets.APP_ID }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 6e7ece3..4e6d2d0 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -57,6 +57,22 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} 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["url"] = "${{ steps.wrangler_deploy.outputs.deployment-url }}"; + + const updatedManifest = JSON.stringify(manifest, null, 2); + fs.writeFileSync(manifestPath, updatedManifest); + console.log('Updated manifest:', updatedManifest); + - name: Write Deployment URL to Summary run: | echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY From 1a17ed1c91b30a709a36cafdc5d4b8c9d606bdf9 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:40:20 +0900 Subject: [PATCH 02/25] chore: updated worker url commit with app login --- .github/workflows/worker-deploy.yml | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 4e6d2d0..bd40964 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -73,6 +73,89 @@ jobs: fs.writeFileSync(manifestPath, updatedManifest); console.log('Updated manifest:', updatedManifest); + - name: Get GitHub App token + if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' + uses: tibdex/github-app-token@v1.7.0 + id: get_installation_token + with: + app_id: ${{ env.APP_ID }} + private_key: ${{ env.APP_PRIVATE_KEY }} + + - name: Update manifest.json + shell: bash + env: + GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token || github.token }} + run: | + git add "manifest.json" + echo "Changed files:" + echo "$(git diff-index --cached --name-only HEAD)" + if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then + node -e " + const fs = require('fs'); + const path = require('path'); + const github = require('@actions/github'); + const manifestPath = path.relative('.', 'manifest.json'); + + async function pushChanges() { + const octokit = github.getOctokit(process.env.GITHUB_TOKEN); + + const context = github.context; + const owner = context.repo.owner; + const repo = context.repo.repo; + const ref = 'heads/${{ github.ref_name }}'; + + try { + const currentCommit = await octokit.rest.git.getRef({ + owner, + repo, + ref + }); + + console.log('Adding file:', manifestPath); + const treeEntries = [ + { + path: manifestPath, + mode: '100644', + type: 'blob', + content: fs.readFileSync(manifestPath, 'utf8'), + } + ]; + const newTree = await octokit.rest.git.createTree({ + owner, + repo, + base_tree: currentCommit.data.object.sha, + tree: treeEntries, + }); + + const newCommit = await octokit.rest.git.createCommit({ + owner, + repo, + message: 'chore: updated manifest.json worker URL', + tree: newTree.data.sha, + parents: [currentCommit.data.object.sha] + }); + + await octokit.rest.git.updateRef({ + owner, + repo, + ref, + sha: newCommit.data.sha, + force: true + }); + + console.log('Changes pushed successfully'); + } catch (error) { + console.error('Error pushing changes:', error); + process.exit(1); + } + } + + pushChanges(); + " + else + echo "No changes to commit" + fi + - name: Write Deployment URL to Summary run: | echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY From 944555af636a865ef135919ec9e8e70d84e8950c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:46:34 +0900 Subject: [PATCH 03/25] chore: added write permission to workflow --- .github/workflows/worker-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index bd40964..25deb5d 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest name: Automatic Cloudflare Deploy environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }} + permissions: write-all steps: - name: Setup Node From 35ed7e0ee5cd7cbc395dd8f2547d7610463a1c30 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:49:32 +0900 Subject: [PATCH 04/25] chore: changed `url` to `homepage_url` --- .github/workflows/worker-deploy.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 25deb5d..52ca474 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -9,7 +9,8 @@ jobs: runs-on: ubuntu-latest name: Automatic Cloudflare Deploy environment: ${{ github.ref == 'refs/heads/main' && 'main' || 'development' }} - permissions: write-all + permissions: + contents: write steps: - name: Setup Node @@ -68,7 +69,7 @@ jobs: const manifestPath = path.resolve("${{ github.workspace }}", './manifest.json'); const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); - manifest["url"] = "${{ steps.wrangler_deploy.outputs.deployment-url }}"; + manifest["homepage_url"] = "${{ steps.wrangler_deploy.outputs.deployment-url }}"; const updatedManifest = JSON.stringify(manifest, null, 2); fs.writeFileSync(manifestPath, updatedManifest); From 26a8d2b482352a67b039b3bd024b693206d0199b Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:50:38 +0900 Subject: [PATCH 05/25] chore: fixed prettier in worker-deploy.yml --- .github/workflows/worker-deploy.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 52ca474..3bc310c 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -97,22 +97,22 @@ jobs: const path = require('path'); const github = require('@actions/github'); const manifestPath = path.relative('.', 'manifest.json'); - + async function pushChanges() { const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - + const context = github.context; const owner = context.repo.owner; const repo = context.repo.repo; const ref = 'heads/${{ github.ref_name }}'; - + try { const currentCommit = await octokit.rest.git.getRef({ owner, repo, ref }); - + console.log('Adding file:', manifestPath); const treeEntries = [ { @@ -128,7 +128,7 @@ jobs: base_tree: currentCommit.data.object.sha, tree: treeEntries, }); - + const newCommit = await octokit.rest.git.createCommit({ owner, repo, @@ -136,7 +136,7 @@ jobs: tree: newTree.data.sha, parents: [currentCommit.data.object.sha] }); - + await octokit.rest.git.updateRef({ owner, repo, @@ -144,14 +144,14 @@ jobs: sha: newCommit.data.sha, force: true }); - + console.log('Changes pushed successfully'); } catch (error) { console.error('Error pushing changes:', error); process.exit(1); } } - + pushChanges(); " else From c186fe0d556a0be5986a90e15261903a6784b999 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:54:23 +0900 Subject: [PATCH 06/25] chore: change run order for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 3bc310c..5da9fb6 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -1,8 +1,11 @@ name: Deploy Worker on: - push: workflow_dispatch: + workflow_run: + workflows: [ "Update Configuration and Build" ] + types: + - completed jobs: deploy-to-cloudflare: From 0c34cfdac092b942f6cce756b7c23427447b29ad Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:56:05 +0900 Subject: [PATCH 07/25] chore: fixed prettier --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 5da9fb6..b6827a3 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -3,7 +3,7 @@ name: Deploy Worker on: workflow_dispatch: workflow_run: - workflows: [ "Update Configuration and Build" ] + workflows: ["Update Configuration and Build"] types: - completed From 911afe16a7854659024aa80da64f0b82ae52d7f5 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 17 Dec 2024 22:58:43 +0900 Subject: [PATCH 08/25] chore: added prettier for manifest.json generation --- .github/workflows/worker-deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index b6827a3..6f72046 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -86,6 +86,12 @@ jobs: 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: Update manifest.json shell: bash env: From 0a74fe42e1ff747a49027f7b61897d51c5c7f56e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:07:14 +0900 Subject: [PATCH 09/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 91 +++++------------------------ 1 file changed, 16 insertions(+), 75 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 6f72046..e836944 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -21,9 +21,6 @@ jobs: with: node-version: "20.10.0" - - name: Enable corepack - run: corepack enable - - uses: actions/checkout@v4 - name: Setup Bun @@ -80,11 +77,21 @@ jobs: - name: Get GitHub App token if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' - uses: tibdex/github-app-token@v1.7.0 - id: get_installation_token + uses: actions/create-github-app-token@v1 + id: app-token with: - app_id: ${{ env.APP_ID }} - private_key: ${{ env.APP_PRIVATE_KEY }} + app-id: ${{ env.APP_ID }} + private-key: ${{ env.APP_PRIVATE_KEY }} + + - name: Get GitHub App User ID + id: get-user-id + run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + + - run: | + git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - name: Format manifest.json using Prettier shell: bash @@ -94,78 +101,12 @@ jobs: - name: Update manifest.json shell: bash - env: - GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token || github.token }} run: | git add "manifest.json" echo "Changed files:" echo "$(git diff-index --cached --name-only HEAD)" - if [ -n "$(git diff-index --cached --name-only HEAD)" ]; then - node -e " - const fs = require('fs'); - const path = require('path'); - const github = require('@actions/github'); - const manifestPath = path.relative('.', 'manifest.json'); - - async function pushChanges() { - const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - - const context = github.context; - const owner = context.repo.owner; - const repo = context.repo.repo; - const ref = 'heads/${{ github.ref_name }}'; - - try { - const currentCommit = await octokit.rest.git.getRef({ - owner, - repo, - ref - }); - - console.log('Adding file:', manifestPath); - const treeEntries = [ - { - path: manifestPath, - mode: '100644', - type: 'blob', - content: fs.readFileSync(manifestPath, 'utf8'), - } - ]; - const newTree = await octokit.rest.git.createTree({ - owner, - repo, - base_tree: currentCommit.data.object.sha, - tree: treeEntries, - }); - - const newCommit = await octokit.rest.git.createCommit({ - owner, - repo, - message: 'chore: updated manifest.json worker URL', - tree: newTree.data.sha, - parents: [currentCommit.data.object.sha] - }); - - await octokit.rest.git.updateRef({ - owner, - repo, - ref, - sha: newCommit.data.sha, - force: true - }); - - console.log('Changes pushed successfully'); - } catch (error) { - console.error('Error pushing changes:', error); - process.exit(1); - } - } - - pushChanges(); - " - else - echo "No changes to commit" - fi + git commit -m "chore: updated manifest.json url" + git push - name: Write Deployment URL to Summary run: | From 76aaa67abfc9a2d7cb8e61c56f87c4c4716d784b Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:11:46 +0900 Subject: [PATCH 10/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index e836944..4e30d13 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -76,7 +76,7 @@ jobs: console.log('Updated manifest:', updatedManifest); - name: Get GitHub App token - if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' + #if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' uses: actions/create-github-app-token@v1 id: app-token with: @@ -92,6 +92,7 @@ jobs: - run: | git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' + if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' - name: Format manifest.json using Prettier shell: bash From 1188b8d495f0eebe7f2ae686889115e35e2f006e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:12:06 +0900 Subject: [PATCH 11/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 4e30d13..1ab61e1 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -92,7 +92,7 @@ jobs: - run: | git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' + #if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' - name: Format manifest.json using Prettier shell: bash From ff742054ac9c98cebb55720b883934064aaad5ff Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:13:56 +0900 Subject: [PATCH 12/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 1ab61e1..44f50cb 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -76,7 +76,7 @@ jobs: console.log('Updated manifest:', updatedManifest); - name: Get GitHub App token - #if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' + if: env.APP_ID != '' && env.APP_PRIVATE_KEY != '' uses: actions/create-github-app-token@v1 id: app-token with: @@ -92,7 +92,7 @@ jobs: - run: | git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - #if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' + if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' - name: Format manifest.json using Prettier shell: bash From 61ab456c5922e0cceb9c6b6268f01cba0bc10f48 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:17:29 +0900 Subject: [PATCH 13/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 44f50cb..a6f33cb 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -102,6 +102,8 @@ jobs: - name: Update manifest.json shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git add "manifest.json" echo "Changed files:" From f17e6c5d41781bfe2f77089dd27e5061f8b31626 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:23:20 +0900 Subject: [PATCH 14/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index a6f33cb..b86ae0d 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -90,9 +90,11 @@ jobs: GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' - git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - if: steps.app-token.outputs.app-slug != '' && steps.get-user-id.outputs.user-id != '' + APP_SLUG="${{ steps.app-token.outputs.app-slug || 'github-actions' }}" + USER_ID="${{ steps.get-user-id.outputs.user-id || 'github-actions' }}" + + git config --global user.name "${APP_SLUG}[bot]" + git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" - name: Format manifest.json using Prettier shell: bash @@ -102,8 +104,6 @@ jobs: - name: Update manifest.json shell: bash - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git add "manifest.json" echo "Changed files:" From 063f11e79d0b7dd116bb6e6f23685a3a15c6faa3 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:27:50 +0900 Subject: [PATCH 15/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index b86ae0d..9936c48 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -89,12 +89,18 @@ jobs: env: GH_TOKEN: ${{ steps.app-token.outputs.token }} - - run: | + - name: 'Set GitHub user' + run: | APP_SLUG="${{ steps.app-token.outputs.app-slug || 'github-actions' }}" - USER_ID="${{ steps.get-user-id.outputs.user-id || 'github-actions' }}" - - git config --global user.name "${APP_SLUG}[bot]" - git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" + USER_ID="${{ steps.get-user-id.outputs.user-id || '' }}" + + if [ -z "$USER_ID" ]; then + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + else + git config --global user.name "${APP_SLUG}[bot]" + git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" + fi - name: Format manifest.json using Prettier shell: bash From 08dccc2c5c11dca6bdb1854399445c85dd250eaa Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:32:16 +0900 Subject: [PATCH 16/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 9936c48..4153cdf 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -7,6 +7,10 @@ on: types: - completed +env: + APP_ID: ${{ secrets.APP_ID }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} + jobs: deploy-to-cloudflare: runs-on: ubuntu-latest From b0c15e9bcada82f19fe3c3854a7e9a6a3ad3843e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:39:11 +0900 Subject: [PATCH 17/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 4153cdf..88ac908 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -93,7 +93,7 @@ jobs: env: GH_TOKEN: ${{ steps.app-token.outputs.token }} - - name: 'Set GitHub user' + - name: "Set GitHub user" run: | APP_SLUG="${{ steps.app-token.outputs.app-slug || 'github-actions' }}" USER_ID="${{ steps.get-user-id.outputs.user-id || '' }}" @@ -112,14 +112,15 @@ jobs: bun add -DE prettier bun prettier --write . - - name: Update manifest.json - shell: bash - run: | - git add "manifest.json" - echo "Changed files:" - echo "$(git diff-index --cached --name-only HEAD)" - git commit -m "chore: updated manifest.json url" - git push + - name: Commit file + uses: swinton/commit@v2.x + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + manifest.json + commit-message: "chore: update manifest.json url" + ref: refs/heads/${{ github.ref }} - name: Write Deployment URL to Summary run: | From 31b426772d35111ff6cdf50f062723d4c5bd1bfd Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:41:27 +0900 Subject: [PATCH 18/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 88ac908..87f29d3 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -120,7 +120,7 @@ jobs: files: | manifest.json commit-message: "chore: update manifest.json url" - ref: refs/heads/${{ github.ref }} + ref: ${{ github.ref }} - name: Write Deployment URL to Summary run: | From 821bb1727ce60ba45e3d148c138f62c29529f36c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:43:51 +0900 Subject: [PATCH 19/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 87f29d3..35919af 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -115,7 +115,7 @@ jobs: - name: Commit file uses: swinton/commit@v2.x env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} with: files: | manifest.json From 616c99ffaec0248cda246589aff339aebf933a64 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:51:53 +0900 Subject: [PATCH 20/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 35919af..f80837e 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -87,25 +87,6 @@ jobs: app-id: ${{ env.APP_ID }} private-key: ${{ env.APP_PRIVATE_KEY }} - - name: Get GitHub App User ID - id: get-user-id - run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - - - name: "Set GitHub user" - run: | - APP_SLUG="${{ steps.app-token.outputs.app-slug || 'github-actions' }}" - USER_ID="${{ steps.get-user-id.outputs.user-id || '' }}" - - if [ -z "$USER_ID" ]; then - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - else - git config --global user.name "${APP_SLUG}[bot]" - git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com" - fi - - name: Format manifest.json using Prettier shell: bash run: | @@ -119,7 +100,7 @@ jobs: with: files: | manifest.json - commit-message: "chore: update manifest.json url" + commit-message: "chore: [skip ci] update manifest.json url" ref: ${{ github.ref }} - name: Write Deployment URL to Summary From a352ad561847d1b38675349301692f66480756d7 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:54:49 +0900 Subject: [PATCH 21/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index f80837e..f367e62 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -100,7 +100,7 @@ jobs: with: files: | manifest.json - commit-message: "chore: [skip ci] update manifest.json url" + commit-message: "chore: update manifest.json url" ref: ${{ github.ref }} - name: Write Deployment URL to Summary From dc7bb9fbcdea01ff21f095b87abecc55517bb48f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 16:58:08 +0900 Subject: [PATCH 22/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index f367e62..0cd0788 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -63,45 +63,45 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} 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/commit@v2.x - env: - GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} - with: - files: | - manifest.json - commit-message: "chore: update manifest.json url" - ref: ${{ github.ref }} +# - 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/commit@v2.x +# env: +# GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} +# with: +# files: | +# manifest.json +# commit-message: "chore: update manifest.json url" +# ref: ${{ github.ref }} - name: Write Deployment URL to Summary run: | From e4eb9729fa8162858e40077949c14e64d9733077 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 17:00:04 +0900 Subject: [PATCH 23/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index 0cd0788..e014636 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -32,7 +32,7 @@ jobs: - 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 From b5ec0f37d9a144f91aacc2877055e1b2c15a3056 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 17:01:51 +0900 Subject: [PATCH 24/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index e014636..a70e9b9 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -63,45 +63,45 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} 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/commit@v2.x -# env: -# GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} -# with: -# files: | -# manifest.json -# commit-message: "chore: update manifest.json url" -# ref: ${{ github.ref }} + - 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/commit@v2.x + env: + GH_TOKEN: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }} + with: + files: | + manifest.json + commit-message: "chore: update manifest.json url" + ref: ${{ github.ref }} - name: Write Deployment URL to Summary run: | From fb9f549514097750514d68da2a8c02ba559e4d33 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 18 Dec 2024 17:03:52 +0900 Subject: [PATCH 25/25] chore: new token workflow for worker-deploy.yml --- .github/workflows/worker-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/worker-deploy.yml b/.github/workflows/worker-deploy.yml index a70e9b9..7a6c481 100644 --- a/.github/workflows/worker-deploy.yml +++ b/.github/workflows/worker-deploy.yml @@ -100,7 +100,7 @@ jobs: with: files: | manifest.json - commit-message: "chore: update manifest.json url" + commit-message: "chore: [skip ci] update manifest.json url" ref: ${{ github.ref }} - name: Write Deployment URL to Summary