From 35dd8f03d26dd0580c00ac398a4c1885d40e3722 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 14:46:11 +0530 Subject: [PATCH 1/4] Improved: firebase configuration for uat env hoisting --- .firebaserc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.firebaserc b/.firebaserc index 8927c1c..b63fe78 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,6 +1,7 @@ { "projects": { "default": "hotwax-digital-commerce", + "uat": "hotwax-digital-commerce-uat", "production": "digital-commerce-71eb8" }, "targets": { @@ -8,7 +9,11 @@ "hosting": { "dev": [ "hotwax-order-routing-dev" - ], + ] + } + }, + "hotwax-digital-commerce-uat": { + "hosting": { "uat": [ "hotwax-order-routing-uat" ] From 70a7ee8b0cb6c3cab1d273248890f6ab1147a2a8 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 14:52:38 +0530 Subject: [PATCH 2/4] Added: firebase hosting file on release --- .github/workflows/firebase-hosting-release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/firebase-hosting-release.yml diff --git a/.github/workflows/firebase-hosting-release.yml b/.github/workflows/firebase-hosting-release.yml new file mode 100644 index 0000000..95f9c36 --- /dev/null +++ b/.github/workflows/firebase-hosting-release.yml @@ -0,0 +1,16 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on release +'on': + push: + tags: + - '*' # Push events to every tag not containing / Refer https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags +jobs: + call-workflow-in-another-repo: + uses: hotwax/dxp-components/.github/workflows/common-firebase-hosting-release.yml@main + with: + config-path: .github/labeler.yml + secrets: + envPAT: ${{ secrets.envPAT }} + HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} \ No newline at end of file From 66c9d853f424324d206ca8354c5345899d7ef223 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 15:18:42 +0530 Subject: [PATCH 3/4] Improved: firebase hosting release --- .../workflows/firebase-hosting-release.yml | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/firebase-hosting-release.yml b/.github/workflows/firebase-hosting-release.yml index 95f9c36..5209aab 100644 --- a/.github/workflows/firebase-hosting-release.yml +++ b/.github/workflows/firebase-hosting-release.yml @@ -1,3 +1,5 @@ +# Not using the common release workflow file from dxp, as for this app we are using a different project for hosting the uat env + # This file was auto-generated by the Firebase CLI # https://github.com/firebase/firebase-tools @@ -7,10 +9,40 @@ name: Deploy to Firebase Hosting on release tags: - '*' # Push events to every tag not containing / Refer https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags jobs: - call-workflow-in-another-repo: - uses: hotwax/dxp-components/.github/workflows/common-firebase-hosting-release.yml@main - with: - config-path: .github/labeler.yml - secrets: - envPAT: ${{ secrets.envPAT }} - HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} \ No newline at end of file + build_and_deploy: + runs-on: ubuntu-latest + environment: development + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Checkout to latest release tag + run: | + git checkout $(git describe --tags `git rev-list --tags --max-count=1`) + - name: Install Dependencies + run: npm install + - name: Generate .env file + run: cp .env.example .env + - name: Set Firebase and VAPID Config + run: | + if [[ -n "$VUE_APP_FIREBASE_CONFIG" ]]; then + sed -i "s|VUE_APP_FIREBASE_CONFIG=.*|VUE_APP_FIREBASE_CONFIG=$VUE_APP_FIREBASE_CONFIG|g" .env + sed -i "s|VUE_APP_FIREBASE_VAPID_KEY=.*|VUE_APP_FIREBASE_VAPID_KEY='$VUE_APP_FIREBASE_VAPID_KEY'|g" .env + sed -i "s|const firebaseConfig =.*|const firebaseConfig = $VUE_APP_FIREBASE_CONFIG|g" public/firebase-messaging-sw.js + fi + env: + VUE_APP_FIREBASE_CONFIG: ${{ secrets.VUE_APP_FIREBASE_CONFIG }} + VUE_APP_FIREBASE_VAPID_KEY: ${{ secrets.VUE_APP_FIREBASE_VAPID_KEY }} + - name: Build + run: npm run build + - name: Install Firebase + run: npm install -g firebase-tools + - name: Set Firebase project + run: firebase use uat --token "$HOTWAX_PUBLIC_SECRET" + env: + HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} + - name: Deploy + run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:uat + env: + HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} \ No newline at end of file From a8281b1334eead535b62c743bd1a60ba25f9a9dd Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Fri, 16 Feb 2024 15:21:26 +0530 Subject: [PATCH 4/4] Removed: firebase and vapid config steps from release workflow --- .github/workflows/firebase-hosting-release.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/firebase-hosting-release.yml b/.github/workflows/firebase-hosting-release.yml index 5209aab..b3c180b 100644 --- a/.github/workflows/firebase-hosting-release.yml +++ b/.github/workflows/firebase-hosting-release.yml @@ -11,7 +11,6 @@ name: Deploy to Firebase Hosting on release jobs: build_and_deploy: runs-on: ubuntu-latest - environment: development steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v3 @@ -24,16 +23,6 @@ jobs: run: npm install - name: Generate .env file run: cp .env.example .env - - name: Set Firebase and VAPID Config - run: | - if [[ -n "$VUE_APP_FIREBASE_CONFIG" ]]; then - sed -i "s|VUE_APP_FIREBASE_CONFIG=.*|VUE_APP_FIREBASE_CONFIG=$VUE_APP_FIREBASE_CONFIG|g" .env - sed -i "s|VUE_APP_FIREBASE_VAPID_KEY=.*|VUE_APP_FIREBASE_VAPID_KEY='$VUE_APP_FIREBASE_VAPID_KEY'|g" .env - sed -i "s|const firebaseConfig =.*|const firebaseConfig = $VUE_APP_FIREBASE_CONFIG|g" public/firebase-messaging-sw.js - fi - env: - VUE_APP_FIREBASE_CONFIG: ${{ secrets.VUE_APP_FIREBASE_CONFIG }} - VUE_APP_FIREBASE_VAPID_KEY: ${{ secrets.VUE_APP_FIREBASE_VAPID_KEY }} - name: Build run: npm run build - name: Install Firebase