chore: fix build & emulation

This commit is contained in:
41666 2021-08-01 16:37:33 -04:00
parent 462ef26ea2
commit 3ca37cff17
5 changed files with 13 additions and 7 deletions

View file

@ -60,7 +60,7 @@ jobs:
- name: Check if already deployed - name: Check if already deployed
id: check id: check
run: | 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::1 \
|| echo ::set-output name=skip::0 || echo ::set-output name=skip::0
@ -86,16 +86,17 @@ jobs:
- run: | - run: |
wrangler init 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 wrangler build
mv worker/script.js worker/${{ matrix.worker }}.js
if: steps.check.outputs.skip == '0' if: steps.check.outputs.skip == '0'
- id: upload-file - id: upload-file
if: github.event_name == 'push' && steps.check.outputs.skip == '0' if: github.event_name == 'push' && steps.check.outputs.skip == '0'
uses: google-github-actions/upload-cloud-storage@main uses: google-github-actions/upload-cloud-storage@main
with: with:
path: worker/script.js path: worker/${{ matrix.worker }}.js
destination: roleypoly-artifacts/backend-worker/${{ github.sha }} destination: roleypoly-artifacts/workers/${{ github.sha }}
credentials: ${{ secrets.GCS_TF_KEY }} credentials: ${{ secrets.GCS_TF_KEY }}
docker_build: docker_build:

View file

@ -34,6 +34,7 @@
"start": "run-p -c start:*", "start": "run-p -c start:*",
"start:bot": "yarn workspace @roleypoly/bot start", "start:bot": "yarn workspace @roleypoly/bot start",
"start:design-system": "yarn workspace @roleypoly/design-system 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:web": "yarn workspace @roleypoly/web start",
"start:worker": "yarn workspace @roleypoly/api start", "start:worker": "yarn workspace @roleypoly/api start",
"test": "jest" "test": "jest"

View file

@ -204,5 +204,6 @@ fork(async () => {
reload(); reload();
}); });
console.log('starting on http://localhost:6609'); const port = args.port || 6609;
server.listen(6609, '0.0.0.0'); console.log(`starting on http://localhost:${port}`);
server.listen(port, '0.0.0.0');

View file

@ -1,3 +1,4 @@
import { interactionHandler } from '@roleypoly/interactions/handlers/interaction';
import { respond } from '@roleypoly/worker-utils'; import { respond } from '@roleypoly/worker-utils';
import { Router } from '@roleypoly/worker-utils/router'; import { Router } from '@roleypoly/worker-utils/router';
import { healthz } from './handlers/healthz'; import { healthz } from './handlers/healthz';
@ -5,7 +6,8 @@ import { uiPublicURI } from './utils/config';
const router = new Router(); const router = new Router();
router.add('GET', '/_healthz', healthz); router.add('GET', '_healthz', healthz);
router.add('POST', 'interaction', interactionHandler);
// Root Zen <3 // Root Zen <3
router.addFallback('root', () => { router.addFallback('root', () => {

View file

@ -9,6 +9,7 @@
"devDependencies": { "devDependencies": {
"@cloudflare/workers-types": "^2.2.2", "@cloudflare/workers-types": "^2.2.2",
"@roleypoly/types": "*", "@roleypoly/types": "*",
"@roleypoly/worker-emulator": "*",
"@roleypoly/worker-utils": "*", "@roleypoly/worker-utils": "*",
"@types/node": "^16.4.10", "@types/node": "^16.4.10",
"tweetnacl": "^1.0.3" "tweetnacl": "^1.0.3"