From 2889ccc6554562ff8f09c4b9601129007f9d0497 Mon Sep 17 00:00:00 2001 From: Max Schmidt Date: Wed, 17 May 2023 12:27:22 +0200 Subject: [PATCH] heya Signed-off-by: Max Schmidt --- .env.dev | 3 +-- .env.prod | 2 +- .github/workflows/push | 0 .github/workflows/push.yml | 17 +++++++++++++++++ astro/src/utils/payload.ts | 9 +++++++-- docker-compose-prod.yml | 2 ++ 6 files changed, 28 insertions(+), 5 deletions(-) delete mode 100644 .github/workflows/push create mode 100644 .github/workflows/push.yml diff --git a/.env.dev b/.env.dev index a895845..865ffee 100644 --- a/.env.dev +++ b/.env.dev @@ -1,7 +1,6 @@ -ASTRO_TO_PAYLOAD_URL=http://payload:3001 -PAYLOAD_SECRET=supersecretkey PAYLOAD_URL=http://localhost:3001 PAYLOAD_PORT=3001 +PAYLOAD_SECRET=supersecretkey MONGODB_URI=mongodb://payload:test@mongo:27017 MONGODB_USER=payload MONGODB_PW=test diff --git a/.env.prod b/.env.prod index 4d8f765..865ffee 100644 --- a/.env.prod +++ b/.env.prod @@ -1,6 +1,6 @@ -PAYLOAD_SECRET=supersecretkey PAYLOAD_URL=http://localhost:3001 PAYLOAD_PORT=3001 +PAYLOAD_SECRET=supersecretkey MONGODB_URI=mongodb://payload:test@mongo:27017 MONGODB_USER=payload MONGODB_PW=test diff --git a/.github/workflows/push b/.github/workflows/push deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..aa5afe6 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,17 @@ +name: Clone or pull repository +on: + branches: + - prod +jobs: + build: + name: Run remote SSH command + runs-on: ubuntu-latest + steps: + - name: Trigger build via ssh + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.KEY }} + script: | + ls diff --git a/astro/src/utils/payload.ts b/astro/src/utils/payload.ts index 57efda9..4729b8d 100644 --- a/astro/src/utils/payload.ts +++ b/astro/src/utils/payload.ts @@ -1,7 +1,12 @@ import type { Post } from "../types"; +const url = + process.env.NODE_ENV === "development" + ? "http://payload:3001" + : `https://${process.env.PAYLOAD_URL}`; + export const getPosts = async () => - (await (await fetch("http://payload:3001/api/posts")).json()).docs as Post[]; + (await (await fetch(`${url}/api/posts`)).json()).docs as Post[]; export const getPost = async (id: string) => - (await (await fetch(`http://payload:3001/api/posts/${id}`)).json()) as Post; + (await (await fetch(`${url}/api/posts/${id}`)).json()) as Post; diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml index 6d2f042..2feb38a 100644 --- a/docker-compose-prod.yml +++ b/docker-compose-prod.yml @@ -3,6 +3,8 @@ services: build: context: astro target: prod + environment: + PAYLOAD_URL: ${PAYLOAD_URL} ports: - 3000:3000