Skip to content

(PROD) Deploy frontend #16

(PROD) Deploy frontend

(PROD) Deploy frontend #16

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# Primary ref: https://dev.to/ckgrafico/deploying-nextjs-to-azure-web-app-with-github-actions-1o9c
name: (PROD) Deploy frontend
on:
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: Production
defaults:
run:
working-directory: frontend
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Setup Node.js version'
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: 'Restore cache'
uses: actions/cache@v3
with:
path: |
frontend/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: 'Install ci dependencies'
run: yarn --frozen-lockfile --ignore-scripts
- name: Build with Next.js (NO)
run: |
yarn build
mv ./build/static ./build/standalone/build
cp -r ./public ./build/standalone/
mv ./build ./build-no
env:
NEXT_PUBLIC_VIBES_BACKEND_URL: ${{ vars.NEXT_PUBLIC_VIBES_BACKEND_URL_NO }}
NEXT_PUBLIC_CLIENT_ID: ${{ vars.NEXT_PUBLIC_CLIENT_ID }}
NEXT_PUBLIC_TENANT_ID: ${{ vars.NEXT_PUBLIC_TENANT_ID }}
NEXT_PUBLIC_APP_SCOPE: ${{ vars.NEXT_PUBLIC_APP_SCOPE }}
- name: Build with Next.js (SE)
run: |
yarn build
mv ./build/static ./build/standalone/build
cp -r ./public ./build/standalone
mv ./build ./build-se
env:
NEXT_PUBLIC_VIBES_BACKEND_URL: ${{ vars.NEXT_PUBLIC_VIBES_BACKEND_URL_SE }}
NEXT_PUBLIC_CLIENT_ID: ${{ vars.NEXT_PUBLIC_CLIENT_ID }}
NEXT_PUBLIC_TENANT_ID: ${{ vars.NEXT_PUBLIC_TENANT_ID }}
NEXT_PUBLIC_APP_SCOPE: ${{ vars.NEXT_PUBLIC_APP_SCOPE }}
- name: Deploy to App Service (NO)
id: deploy-to-webapp-no
uses: azure/webapps-deploy@v2
with:
app-name: 'vibes-frontend-norway-prod'
slot-name: 'Production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_FRONTEND_NO }}
package: ./frontend/build-no/standalone
- name: Deploy to App Service (SE)
id: deploy-to-webapp-se
uses: azure/webapps-deploy@v2
with:
app-name: 'vibes-frontend-sweden-prod'
slot-name: 'Production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_FRONTEND_SE }}
package: ./frontend/build-se/standalone