From eb1b9168ad5e855a628712cef8fb2955492ce197 Mon Sep 17 00:00:00 2001 From: Ole Magnus Fon Johnsen Date: Tue, 24 Sep 2024 13:20:12 +0200 Subject: [PATCH] Add deploy script --- .github/workflows/deploy.yaml | 25 +++++++++++++++++++++++++ apps/api/src/index.ts | 4 +++- playwright/playwright.config.ts | 10 +++++----- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000000..66d6627867 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,25 @@ +name: 🚀 Deploy + +on: + push: + branches: + - main + +jobs: + api: + runs-on: ubuntu-latest + + steps: + - name: 🔍 Checkout + uses: actions/checkout@v4 + + - name: 📦 Install dependencies + uses: ./.github/actions/pnpm-install + + - name: 🪰 Setup Fly + uses: superfly/flyctl-actions/setup-flyctl@master + + - name: 🚀 Deploy + run: flyctl deploy --config apps/api/fly.toml --dockerfile apps/api/Dockerfile --remote-only + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 552a421d12..071ccb8cd7 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -4,11 +4,13 @@ import app from "./app"; const PORT = process.env.API_PORT ? Number(process.env.API_PORT) : 8000; +const isCI = !!process.env.CI; + serve( { fetch: app.fetch, port: PORT, - hostname: "127.0.0.1", + hostname: isCI ? "localhost" : "0.0.0.0", }, (info) => { console.log(`Listening on http://localhost:${info.port}`); diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index 42760177cf..c585f7bedc 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -18,15 +18,15 @@ export default defineConfig({ webServer: [ { - command: "pnpm run dev", + command: "pnpm run start", cwd: "../apps/web", - url: "http://127.0.0.1:3000", + url: "http://localhost:3000", reuseExistingServer: !isCI, }, { - command: "pnpm run dev", + command: "pnpm run start", cwd: "../apps/api", - url: "http://127.0.0.1:8000", + url: "http://localhost:8000", reuseExistingServer: !isCI, stdout: "pipe", }, @@ -34,7 +34,7 @@ export default defineConfig({ use: { headless: isCI, - baseURL: "http://127.0.0.1:3000", + baseURL: "http://localhost:3000", video: "retain-on-failure", trace: "retain-on-failure", timezoneId: "Europe/Oslo",