[DEV-3017] Improve scroll-to behaviour for TutorialsList and UseCaseL… #272
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\"}]}" | |
fi | |
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT | |
deploy: | |
name: Deploy standalone website ${{ matrix.environment }} | |
if: ${{ needs.setup.outputs.matrix != '' }} | |
runs-on: codebuild-${{ matrix.environment }}-github-runner-${{ github.run_id }}-${{ github.run_attempt }} | |
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: Cache npm dependencies | |
id: cache-npm | |
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Install dependencies | |
run: |- | |
npm config set cache ~/.npm | |
npm ci --audit=false --fund=false --prefer-offline --max-parallel=5 | |
- 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: Clean up config files | |
working-directory: apps/nextjs-website/.open-next | |
run: | | |
find ./ -type f -name ".env" -delete | |
- 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 | |
- name: Invoke Lambda DynamoDB Provider | |
run: | | |
aws lambda invoke \ | |
--function-name devportal-${{ env.ENV_SHORT }}-website-opnext-init-lambda-01 \ | |
--region eu-south-1 \ | |
--payload '{}' \ | |
response.json | |
- name: Publish new Lambda version for Server function | |
uses: ./.github/actions/publish_new_lambda_version | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-server-lambda-01 | |
alias_name: production | |
- name: Publish new Lambda version for Image Optimization function | |
uses: ./.github/actions/publish_new_lambda_version | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-img-opt-lambda-01 | |
alias_name: production | |
- name: Publish new Lambda version for Revalidation function | |
uses: ./.github/actions/publish_new_lambda_version | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-isr-lambda-01 | |
alias_name: production | |
- name: Publish new Lambda version for DynamoDB Provider function | |
uses: ./.github/actions/publish_new_lambda_version | |
with: | |
function_name: devportal-${{ env.ENV_SHORT }}-website-opnext-init-lambda-01 | |
alias_name: production | |
- name: Invalidate CloudFront cache | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ vars.OPENNEXT_CLOUDFRONT_DISTRIBUTION_ID }} \ | |
--paths "/*" |