From 3ca37cff179dfb6de9f20b8f7ea56159666e9b20 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Sun, 1 Aug 2021 16:37:33 -0400 Subject: [PATCH] chore: fix build & emulation --- .github/workflows/build.yml | 9 +++++---- package.json | 1 + packages/backend-emulator/main.js | 5 +++-- packages/interactions/index.ts | 4 +++- packages/interactions/package.json | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5d6cbe..bf7e1a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,7 @@ jobs: - name: Check if already deployed id: check run: | - gsutil stat gs://roleypoly-artifacts/backend-worker/${{ github.sha }}/script.js \ + gsutil stat gs://roleypoly-artifacts/workers/${{ github.sha }}/${{ matrix.worker }}.js \ && echo ::set-output name=skip::1 \ || echo ::set-output name=skip::0 @@ -86,16 +86,17 @@ jobs: - run: | wrangler init - echo 'webpack_config = "packages/api/webpack.config.js"' | tee -a wrangler.toml + echo 'webpack_config = "packages/${{ matrix.worker }}/webpack.config.js"' | tee -a wrangler.toml wrangler build + mv worker/script.js worker/${{ matrix.worker }}.js if: steps.check.outputs.skip == '0' - id: upload-file if: github.event_name == 'push' && steps.check.outputs.skip == '0' uses: google-github-actions/upload-cloud-storage@main with: - path: worker/script.js - destination: roleypoly-artifacts/backend-worker/${{ github.sha }} + path: worker/${{ matrix.worker }}.js + destination: roleypoly-artifacts/workers/${{ github.sha }} credentials: ${{ secrets.GCS_TF_KEY }} docker_build: diff --git a/package.json b/package.json index 68be7e1..93b8bb9 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "start": "run-p -c start:*", "start:bot": "yarn workspace @roleypoly/bot start", "start:design-system": "yarn workspace @roleypoly/design-system start", + "start:interactions": "yarn workspace @roleypoly/interactions start", "start:web": "yarn workspace @roleypoly/web start", "start:worker": "yarn workspace @roleypoly/api start", "test": "jest" diff --git a/packages/backend-emulator/main.js b/packages/backend-emulator/main.js index 0895e4e..ebd9613 100755 --- a/packages/backend-emulator/main.js +++ b/packages/backend-emulator/main.js @@ -204,5 +204,6 @@ fork(async () => { reload(); }); -console.log('starting on http://localhost:6609'); -server.listen(6609, '0.0.0.0'); +const port = args.port || 6609; +console.log(`starting on http://localhost:${port}`); +server.listen(port, '0.0.0.0'); diff --git a/packages/interactions/index.ts b/packages/interactions/index.ts index a76af6e..997ecb4 100644 --- a/packages/interactions/index.ts +++ b/packages/interactions/index.ts @@ -1,3 +1,4 @@ +import { interactionHandler } from '@roleypoly/interactions/handlers/interaction'; import { respond } from '@roleypoly/worker-utils'; import { Router } from '@roleypoly/worker-utils/router'; import { healthz } from './handlers/healthz'; @@ -5,7 +6,8 @@ import { uiPublicURI } from './utils/config'; const router = new Router(); -router.add('GET', '/_healthz', healthz); +router.add('GET', '_healthz', healthz); +router.add('POST', 'interaction', interactionHandler); // Root Zen <3 router.addFallback('root', () => { diff --git a/packages/interactions/package.json b/packages/interactions/package.json index 6a955d9..5b78e15 100644 --- a/packages/interactions/package.json +++ b/packages/interactions/package.json @@ -9,6 +9,7 @@ "devDependencies": { "@cloudflare/workers-types": "^2.2.2", "@roleypoly/types": "*", + "@roleypoly/worker-emulator": "*", "@roleypoly/worker-utils": "*", "@types/node": "^16.4.10", "tweetnacl": "^1.0.3"