From 90a913edb4dd62e896d9a21c26cd8c368bb47fe4 Mon Sep 17 00:00:00 2001 From: Matthew Warman Date: Wed, 16 Oct 2024 07:30:47 -0400 Subject: [PATCH] prebuild script for Appflow env --- .appflow/scripts/prebuild.sh | 20 ++++++++++++++++++++ .gitignore | 5 +---- package.json | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100755 .appflow/scripts/prebuild.sh diff --git a/.appflow/scripts/prebuild.sh b/.appflow/scripts/prebuild.sh new file mode 100755 index 0000000..c8313be --- /dev/null +++ b/.appflow/scripts/prebuild.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# npm hook run before the build script +# see: https://ionic.io/docs/appflow/automation/environments + +# echo ">>> prebuild script" + +# create .env file if running in Ionic Appflow +if [ "$CI_AUTOMATED_BUILD" = "1" ] +then + echo "Appflow build; creating .env file" + echo "VITE_BUILD_DATE=$(date +'%Y-%m-%d')" > .env + echo "VITE_BUILD_TIME=$(date +'%H:%M:%S%z')" >> .env + echo "VITE_BUILD_TS=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> .env + echo "VITE_BUILD_COMMIT_SHA=$CI_GIT_COMMIT_SHA" >> .env + echo "VITE_BUILD_WORKFLOW_NAME=$CI_AUTOMATION_NAME" >> .env + echo "VITE_BUILD_WORKFLOW_RUN_NUMBER=$CI_BUILD_NUMBER" >> .env + echo "VITE_BUILD_WORKFLOW_RUN_ATTEMPT=1" >> .env +else + echo "NOT an Appflow build; skipping .env file creation" +fi diff --git a/.gitignore b/.gitignore index bad4d28..c4c5b40 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,7 @@ # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local +.env* /.nx /.nx/cache /.vscode/* diff --git a/package.json b/package.json index 50af995..0b36802 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "type": "module", "scripts": { "dev": "vite", + "prebuild": "./.appflow/scripts/prebuild.sh", "build": "tsc && vite build", "preview": "vite preview", "test": "vitest",