Update PAYLOAD_SERVER_URL to PAYLOAD_URL and remove unused env var

This commit is contained in:
Max Schmidt 2023-06-07 10:53:39 +02:00
parent fe5a99f370
commit 2c3b26a809
6 changed files with 18 additions and 19 deletions

6
.env
View File

@ -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
TOKEN=supersecrettoken

View File

@ -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

View File

@ -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.

View File

@ -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[];

View File

@ -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}

View File

@ -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,
},