Skip to content

Deploy Standalone Website #4

Deploy Standalone Website

Deploy Standalone Website #4

name: Deploy Standalone Website
on:
push:
branches:
- "main"
paths:
- "**/apps/nextjs-website/**"
workflow_dispatch:
inputs:
environment:
description: 'Choose environment'
type: choice
required: true
default: dev
options:
- dev
- uat
- prod
jobs:
setup:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
permissions:
id-token: write
contents: read
steps:
- name: Set Dynamic Env Matrix
id: setmatrix
run: |
echo "github.ref ${{ github.ref }}"
echo "event name ${{ github.event_name }}"
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
matrixStringifiedObject="{\"include\":[{\"environment\":\"${{ github.event.inputs.environment }}\"}]}"
else
matrixStringifiedObject="{\"include\":[{\"environment\":\"dev\"}, {\"environment\":\"uat\"}]}"
fi
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
deploy:
name: Deploy standalone website ${{ matrix.environment }}
if: ${{ needs.setup.outputs.matrix != '' }}
runs-on: ubuntu-24.04
needs: [ setup ]
strategy:
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
continue-on-error: false
environment: ${{ matrix.environment }}
env:
ENV_SHORT: ${{ fromJSON('{"dev":"d","uat":"u","prod":"p"}')[matrix.environment] }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
with:
submodules: recursive
- name: Setup Node.JS
uses: ./.github/actions/setup-node
- name: Install dependencies
run: npm i --audit=false --fund=false
- name: Build NextJS website
run: npm run build -w nextjs-website
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
role-to-assume: ${{ vars.IAM_ROLE_DEPLOY_LAMBDA }}
aws-region: eu-south-1
- name: Deploy Lambda function (${{ matrix.environment }})
run: |
aws lambda update-function-code \
--function-name devportal-${{ env.ENV_SHORT }}-website-opnext-server-lambda-01 \
--zip-file fileb://nextjs-app.zip --region eu-south-1