mirror of
https://mau.dev/andreijiroh-dev/website.git
synced 2025-06-24 21:34:22 +00:00
fix(scripts): 🔨 patch scripts for environment detection stuff [skip ci]
Signed-off-by: Andrei Jiroh Halili <ajhalili2006@gmail.com>
This commit is contained in:
parent
7e3ba7df54
commit
81902a0b3c
3 changed files with 84 additions and 2 deletions
52
bin/deploykit-pages.sh
Executable file
52
bin/deploykit-pages.sh
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ $DEBUG != "" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
## source vars from .env first ##
|
||||
_root_directory_git=$(git rev-parse --show-toplevel)
|
||||
export "$(xargs < "$_root_directory_git/.env")"
|
||||
|
||||
_branch_name_git=$(git rev-parse --abbrev-ref HEAD)
|
||||
_commit_sha=$(git rev-parse HEAD)
|
||||
_commit_sha_short=$(git rev-parse --short HEAD)
|
||||
_command_prefix="npx wrangler pages publish $_root_directory_git/public --project-name $CF_PAGES_PROJECT_NAME --branch $_branch_name_git --commit-hash $_commit_sha"
|
||||
|
||||
warn() {
|
||||
echo "warning: $*"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo "error: $*"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "info: $*"
|
||||
}
|
||||
|
||||
if [[ $_branch_name_git == "main" ]]; then
|
||||
DEPLOY_COMMAND="$_command_prefix --env production"
|
||||
elif [[ $CI_PIPELINE_SOURCE == "merge_request" ]]; then
|
||||
DEPLOY_COMMAND="$_command_prefix --env pr-#CI_MERGE_REQUEST_ID"
|
||||
fi
|
||||
|
||||
if ! git diff-index --quiet HEAD -- && [[ $FF_DIRTY_DEPLOY != "true" ]]; then
|
||||
error Possible dirty working directory, aborting for safety reasons...
|
||||
info To deploy while still dirty, set FF_DIRTY_DEPLOY=true on next invocation.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$_root_directory_git/public" ]]; then
|
||||
bash "$_root_directory_git/bin/build.sh"
|
||||
fi
|
||||
|
||||
if [[ $FF_DIRTY_DEPLOY == "true" ]]; then
|
||||
$DEPLOY_COMMAND --commit-dirty
|
||||
else
|
||||
${DEPLOY_COMMAND:-"$_command_prefix"}
|
||||
fi
|
||||
|
||||
if [[ $DEBUG != "" ]]; then
|
||||
set +x
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue