From 2f4c3e54d358cf2d30cc1768066d987e665606e4 Mon Sep 17 00:00:00 2001 From: Aditya Sharma Date: Wed, 23 Nov 2022 17:28:46 +0530 Subject: [PATCH] Implemented autodeploy flow for uat --- .firebaserc | 13 +++++- .github/workflows/firebase-hosting-merge.yml | 2 +- .../workflows/firebase-hosting-release.yml | 32 +++++++++++++ firebase.json | 45 +++++++++++++++++-- 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/firebase-hosting-release.yml diff --git a/.firebaserc b/.firebaserc index 3cc75edec..ac97dbea6 100644 --- a/.firebaserc +++ b/.firebaserc @@ -6,15 +6,24 @@ "targets": { "hotwax-digital-commerce": { "hosting": { - "bopis-dev": [ + "dev": [ "bopis-dev" + ], + "uat": [ + "bopis-uat" ] } }, "digital-commerce-71eb8": { "hosting": { - "hotwax-bopis": [ + "prod": [ "hotwax-bopis" + ], + "prod-v1": [ + "hotwax-bopis" + ], + "prod-v2": [ + "hotwax-bopis-v2" ] } } diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index eedc5d8dd..3718e4ce9 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -24,6 +24,6 @@ jobs: env: HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} - name: Deploy - run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:bopis-dev + run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:dev env: HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} diff --git a/.github/workflows/firebase-hosting-release.yml b/.github/workflows/firebase-hosting-release.yml new file mode 100644 index 000000000..a1a8baaad --- /dev/null +++ b/.github/workflows/firebase-hosting-release.yml @@ -0,0 +1,32 @@ +# 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: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - 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: Build + run: npm run build + - name: Install Firebase + run: npm install -g firebase-tools + - name: Set Firebase project + run: firebase use default --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 }} diff --git a/firebase.json b/firebase.json index a4839a628..37e88fe87 100644 --- a/firebase.json +++ b/firebase.json @@ -1,7 +1,7 @@ { "hosting": [ { - "target": "hotwax-bopis", + "target": "prod", "public": "dist", "ignore": [ "firebase.json", @@ -12,10 +12,48 @@ "source": "**", "destination": "/index.html" } ] - }, { - "target": "bopis-dev", + "target": "prod-v1", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ { + "source": "**", + "destination": "/index.html" + } ] + }, + { + "target": "prod-v2", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ { + "source": "**", + "destination": "/index.html" + } ] + }, + { + "target": "dev", + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ { + "source": "**", + "destination": "/index.html" + } ] + }, + { + "target": "uat", "public": "dist", "ignore": [ "firebase.json", @@ -26,7 +64,6 @@ "source": "**", "destination": "/index.html" } ] - } ] }