diff --git a/.env b/.env index 083ef1c..86e04b5 100644 --- a/.env +++ b/.env @@ -1,10 +1,10 @@ +NAME=astroad ASTRO_HOST=localhost:3000 PAYLOAD_HOST=payload:3001 -PAYLOAD_SERVER_URL=http://localhost:3001 +PAYLOAD_URL=http://localhost:3001 PAYLOAD_PORT=3001 PAYLOAD_SECRET=supersecretkey MONGODB_URI=mongodb://payload:test@mongo:27017 MONGODB_USER=payload MONGODB_PW=test -TOKEN=supersecrettoken -NAME=astroad \ No newline at end of file +TOKEN=supersecrettoken \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 373424d..615a509 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -37,25 +37,24 @@ jobs: replace_env() { local env_var=$1 local new_value=$2 - local file=$3 - sed -i "s/${env_var}=.*/${env_var}=${new_value}/" $file + sed -i "s/${env_var}=.*/${env_var}=${new_value}/" .env } cd ${{ secrets.PATH }} # Replace .env with vars - replace_env 'NAME' '${{ vars.NAME }}' .env - replace_env 'ASTRO_HOST' '${{ vars.ASTRO_HOST }}' .env - replace_env 'PAYLOAD_HOST' '${{ vars.PAYLOAD_HOST }}' .env - replace_env 'PAYLOAD_SERVER_URL' '${{ vars.PAYLOAD_SERVER_URL }}' .env - replace_env 'PAYLOAD_PORT' '${{ vars.PAYLOAD_PORT }}' .env + replace_env 'NAME' '${{ vars.NAME }}' + replace_env 'ASTRO_HOST' '${{ vars.ASTRO_HOST }}' + replace_env 'PAYLOAD_HOST' '${{ vars.PAYLOAD_HOST }}' + replace_env 'PAYLOAD_URL' '${{ vars.PAYLOAD_URL }}' + replace_env 'PAYLOAD_PORT' '${{ vars.PAYLOAD_PORT }}' # Replace .env with secrets - replace_env 'PAYLOAD_SECRET' '${{ secrets.PAYLOAD_SECRET }}' .env - replace_env 'MONGODB_URI' '${{ secrets.MONGODB_URI }}' .env - replace_env 'MONGODB_USER' '${{ secrets.MONGODB_USER }}' .env - replace_env 'MONGODB_PW' '${{ secrets.MONGODB_PW }}' .env - replace_env 'TOKEN' '${{ secrets.TOKEN }}' .env + replace_env 'PAYLOAD_SECRET' '${{ secrets.PAYLOAD_SECRET }}' + replace_env 'MONGODB_URI' '${{ secrets.MONGODB_URI }}' + replace_env 'MONGODB_USER' '${{ secrets.MONGODB_USER }}' + replace_env 'MONGODB_PW' '${{ secrets.MONGODB_PW }}' + replace_env 'TOKEN' '${{ secrets.TOKEN }}' mkdir -p ./astro cp .env ./astro/.env diff --git a/README.md b/README.md index be4cc01..43a6fdd 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Variables: - ASTRO_HOST: Hostdomain of the Frontend - PAYLOAD_HOST: Hostdomain of the CMS -- PAYLOAD_SERVER_URL: URL of the CMS +- PAYLOAD_URL: URL of the CMS - NAME: Name of the Container and Project Please remember to set these secrets and variables in your repository settings to ensure a successful deployment through Github Workflows. diff --git a/astro/src/utils/payload.ts b/astro/src/utils/payload.ts index 816a1a8..6659f5e 100644 --- a/astro/src/utils/payload.ts +++ b/astro/src/utils/payload.ts @@ -2,7 +2,7 @@ import type { Post } from "../types"; const url = import.meta.env.DEV ? "http://payload:3001" - : `${import.meta.env.PAYLOAD_SERVER_URL}`; + : `${import.meta.env.PAYLOAD_URL}`; export const getPosts = async () => (await (await fetch(`${url}/api/posts`)).json()).docs as Post[]; diff --git a/docker-compose.yml b/docker-compose.yml index 5f6c04f..f857d53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: build: context: payload environment: - PAYLOAD_SERVER_URL: ${PAYLOAD_SERVER_URL} + PAYLOAD_URL: ${PAYLOAD_URL} PAYLOAD_PORT: ${PAYLOAD_PORT} PAYLOAD_SECRET: ${PAYLOAD_SECRET} MONGODB_URI: ${MONGODB_URI} diff --git a/payload/src/payload.config.ts b/payload/src/payload.config.ts index b03bae9..5e26027 100644 --- a/payload/src/payload.config.ts +++ b/payload/src/payload.config.ts @@ -5,7 +5,7 @@ import Users from "./collections/Users"; import Media from "./collections/Media"; export default buildConfig({ - serverURL: process.env.PAYLOAD_SERVER_URL, + serverURL: process.env.PAYLOAD_URL, admin: { user: Users.slug, },