Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Gitpod for one-click quickstart #58

Merged
merged 12 commits into from
Apr 15, 2022
Prev Previous commit
Next Next commit
(dev) Improve .env logic
  • Loading branch information
jacobparis committed Apr 9, 2022
commit 4d70750074f662781f0a905ad2b5693f6b4fedd3
30 changes: 25 additions & 5 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,31 @@ ports:
tasks:
- name: Restore .env file
command: |
if [ -n "${ENV}" ]; then
# restore the .env file from gitpod user's env vars
echo "${ENV}" | tee .env > /dev/null
eval $(gp env -e ENV="$(base64 .env | tr -d '\n')")
echo "${ENV}" | base64 -d | tee .env > /dev/null
if [ -f .env ]; then
# If this workspace already has a .env, don't override it
# Local changes survive a workspace being opened and closed
# but they will not persist between separate workspaces for the same repo

echo "Found .env in workspace"
else
# There is no .env
if [ ! -n "${ENV}" ]; then
# There is no $ENV from a previous workspace
# Default to the example .env
echo "Setting example .env"

cp .env.example .env
else
# After making changes to .env, run this line to persist it to $ENV
# eval $(gp env -e ENV="$(base64 .env | tr -d '\n')")
#
# Environment variables set this way are shared between all your workspaces for this repo
# The lines below will read $ENV and print a .env file

echo "Restoring .env from Gitpod"

echo "${ENV}" | base64 -d | tee .env > /dev/null
fi
fi

- init: npm install && npm run setup
Expand Down