diff --git a/.github/workflows/firebase-hosting-prod.yml b/.github/workflows/firebase-hosting-prod.yml new file mode 100644 index 0000000..993e951 --- /dev/null +++ b/.github/workflows/firebase-hosting-prod.yml @@ -0,0 +1,62 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy Frontend to Firebase Hosting PROD +on: + workflow_dispatch: +jobs: + build_and_deploy: + runs-on: ubuntu-latest + environment: prod + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node- + - name: Cache Next.js build + uses: actions/cache@v3 + with: + path: ${{ github.workspace }}/frontend/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies and build + env: + APP_ENV: prod + NEXT_PUBLIC_API_BASE_URL: ${{ vars.NEXT_PUBLIC_API_BASE_URL }} + NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} + NEXT_PUBLIC_FIREBASE_API_KEY: ${{ vars.NEXT_PUBLIC_FIREBASE_API_KEY }} + NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} + NEXT_PUBLIC_FIREBASE_APP_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_APP_ID }} + run: | + cd frontend + npm ci + npm install sharp + npm run build + - name: Debug Variables + run: | + echo "Using vars context: ${{ vars.NEXT_PUBLIC_API_BASE_URL }}" + echo "Current branch: ${{ github.ref_name }}" + echo "All environment variables:" + env + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SCHEMESSG_V3_PROD }} + channelId: live + projectId: schemessg + target: prod + entryPoint: ./frontend + env: + FIREBASE_CLI_EXPERIMENTS: webframeworks + NEXT_PUBLIC_API_BASE_URL: ${{ vars.NEXT_PUBLIC_API_BASE_URL }} + NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }} + NEXT_PUBLIC_FIREBASE_API_KEY: ${{ vars.NEXT_PUBLIC_FIREBASE_API_KEY }} + NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_PROJECT_ID }} + NEXT_PUBLIC_FIREBASE_APP_ID: ${{ vars.NEXT_PUBLIC_FIREBASE_APP_ID }} diff --git a/frontend/.firebaserc b/frontend/.firebaserc index 7503196..b56745a 100644 --- a/frontend/.firebaserc +++ b/frontend/.firebaserc @@ -1,6 +1,7 @@ { "projects": { - "default": "schemessg-v3-dev" + "default": "schemessg-v3-dev", + "prod": "schemessg" }, "targets": { "schemessg-v3-dev": { @@ -9,8 +10,15 @@ "schemessg-v3-dev" ] } + }, + "schemessg": { + "hosting": { + "prod": [ + "schemessg" + ] + } } }, "etags": {}, "dataconnectEmulatorConfig": {} -} \ No newline at end of file +} diff --git a/frontend/firebase.json b/frontend/firebase.json index 16fc821..66c846b 100644 --- a/frontend/firebase.json +++ b/frontend/firebase.json @@ -1,14 +1,28 @@ { - "hosting": [{ - "target": "staging", - "source": ".", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], - "frameworksBackend": { - "region": "asia-east1" + "hosting": [ + { + "target": "staging", + "source": ".", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "frameworksBackend": { + "region": "asia-southeast1" + } + }, + { + "target": "prod", + "source": ".", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "frameworksBackend": { + "region": "asia-southeast1" + } } - }] + ] }