Skip to content

Deploy Standalone Website #5

Deploy Standalone Website

Deploy Standalone Website #5

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 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
S3_ACCESS_KEY_ID: ${{ AWS_ACCESS_KEY_ID }}

Check failure on line 96 in .github/workflows/deploy_standalone.yaml

View workflow run for this annotation

GitHub Actions / Deploy Standalone Website

Invalid workflow file

The workflow is not valid. .github/workflows/deploy_standalone.yaml (Line: 96, Col: 29): Unrecognized named-value: 'AWS_ACCESS_KEY_ID'. Located at position 1 within expression: AWS_ACCESS_KEY_ID .github/workflows/deploy_standalone.yaml (Line: 97, Col: 33): Unrecognized named-value: 'AWS_SECRET_ACCESS_KEY'. Located at position 1 within expression: AWS_SECRET_ACCESS_KEY
S3_SECRET_ACCESS_KEY: ${{ AWS_SECRET_ACCESS_KEY }}
S3_SESSION_TOKEN: ${{ AWS_SESSION_TOKEN }}
- 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