Deploy Standalone Website #13
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
with: | |
package_manager: npm | |
- name: Install dependencies | |
run: npm ci --audit=false --fund=false | |
- name: Compile | |
run: npm run compile | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 | |
with: | |
role-to-assume: ${{ secrets.IAM_ROLE_DEPLOY_LAMBDA }} | |
aws-region: eu-south-1 | |
- name: Setup env variables | |
working-directory: apps/nextjs-website | |
run: | | |
aws lambda get-function-configuration \ | |
--function-name devportal-${{ env.ENV_SHORT }}-website-opnext-server-lambda-01 | jq -r '.Environment.Variables | to_entries[] | "\(.key)=\(.value)"' > .env | |
- name: build open-next | |
working-directory: apps/nextjs-website | |
run: npx @opennextjs/aws build | |
env: | |
AWS_REGION: eu-south-1 | |
- name: Sync Assets to S3 | |
working-directory: apps/nextjs-website | |
run: | | |
aws s3 sync ./.open-next/assets s3://devportal-${{ env.ENV_SHORT }}-website-opnext-assets-01/_assets | |
- name: Sync Cache to S3 | |
working-directory: apps/nextjs-website | |
run: | | |
aws s3 sync ./.open-next/cache s3://devportal-${{ env.ENV_SHORT }}-website-opnext-assets-01/_cache | |
- name: Deploy Lambda Server Function | |
uses: ./.github/actions/deploy_lambda | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-server-lambda-01 | |
working-directory: apps/nextjs-website/.open-next/server-functions/default | |
s3_bucket: devportal-${{ env.ENV_SHORT }}-website-opennext-lambda-code-01 | |
- name: Deploy Lambda Image Optimization | |
uses: ./.github/actions/deploy_lambda | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-img-opt-lambda-01 | |
working-directory: apps/nextjs-website/.open-next/image-optimization-function | |
s3_bucket: devportal-${{ env.ENV_SHORT }}-website-opennext-lambda-code-01 | |
- name: Deploy Lambda DynamoDB Provider | |
uses: ./.github/actions/deploy_lambda | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-init-lambda-01 | |
working-directory: apps/nextjs-website/.open-next/dynamodb-provider | |
s3_bucket: devportal-${{ env.ENV_SHORT }}-website-opennext-lambda-code-01 | |
- name: Deploy Lambda Revalidation Function | |
uses: ./.github/actions/deploy_lambda | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-isr-lambda-01 | |
working-directory: apps/nextjs-website/.open-next/revalidation-function | |
s3_bucket: devportal-${{ env.ENV_SHORT }}-website-opennext-lambda-code-01 |