This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
forked from gitpod-io/workspace-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add support for dotenv var exporting
Script for manual reloading without issuing direnv reload command should arrive within this week, as I need to check if I borked the CI. Signed-off-by: Andrei Jiroh Eugenio Halili <[email protected]>
- Loading branch information
1 parent
958c4ef
commit f3cd9e1
Showing
2 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This is an example dotenv file for everyone to duplicate as .env. Remember not to | ||
# commit secrets! | ||
|
||
# Change text editors, especially if you're inside an container. | ||
# EDITOR=nano | ||
# VISUAL=nano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2155 | ||
|
||
REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
export PATH="$REPO_ROOT/.gitlab/ci/scripts:$PATH" | ||
export REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
export PATH="$REPO_ROOT/.gitlab/ci/scripts:$REPO_ROOT/devkit/bin:$PATH" | ||
|
||
# Simulate GitLab CI environment as much as possible. | ||
# Simulate GitLab CI environment as much as possible. The only problem would be if the URL is SSH clone one. | ||
export CI_PROJECT_URL=$(git remote get-url origin) | ||
# https://stackoverflow.com/a/50126161 | ||
export CI_PROJECT_PATH="$(grep -Po '\w\K/\w+[^?]+' <<< "$CI_PROJECT_URL")" | ||
# https://gist.github.com/oneohthree/f528c7ae1e701ad990e6#gistcomment-2862791 | ||
CI_PROJECT_PATH_SLUG_TMP="$(echo "$CI_PROJECT_PATH" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z)" | ||
export CI_PROJECT_PATH_SLUG=${CI_PROJECT_PATH_SLUG_TMP:-"gitpodify-gitpodified-wworkspace-images"} | ||
# Tip: If you really need to simulate some scripts in an GitLab MR context, | ||
# touch .emulate-gitlab-mergerequest-pipelines in the root directory of this repo. | ||
|
||
# Tip: If you really need to simulate some scripts in an GitLab MR context, touch .emulate-gitlab-mergerequest-pipelines | ||
# in the root directory of this repo, then `direnv reload`. | ||
if [[ -f "${REPO_ROOT:-"$PWD"}/.emulate-gitlab-mergerequest-pipelines" ]]; then | ||
export CI_PIPELINE_SOURCE="merge_request_event" | ||
fi | ||
fi | ||
|
||
# Export key-value pairs with this magic from dotenv. | ||
if [ -f .env ]; then | ||
export $(echo $(cat ".env" | sed 's/#.*//g'| xargs) | envsubst) | ||
fi |