Skip to content

Update to disable AWS lambda push and change dependency manager from … #14

Update to disable AWS lambda push and change dependency manager from …

Update to disable AWS lambda push and change dependency manager from … #14

name: Update Gateway lambdas (staging)
# Disabled for now. We need to add a current version of the functions to enable this.
# on:
# push:
# branches:
# - dev
# paths:
# - 'apps/summerfi-api/**'
# - '.github/workflows/aws-staging-gateway.yaml'
defaults:
run:
working-directory: ./apps/summerfi-api
jobs:
deploy_zip:
name: Deploy lambda functions from zip
runs-on: ubuntu-latest
environment: staging
env:
ASSETS_LAMBDA: summer-fi-portfolio-assets-staging
OVERVIEW_LAMBDA: summer-fi-portfolio-overview-staging
ASSETS_LAMBDA_ZIP_PATH: ./apps/summerfi-api/artifacts/portfolio-assets.zip
OVERVIEW_LAMBDA_ZIP_PATH: ./apps/summerfi-api/artifacts/portfolio-overview.zip
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.STAGING_GW_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGING_GW_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.STAGING_AWS_REGION }}
- name: Install dependencies
run: |
pnpm install
- name: Create bundle
run: |
pnpm run build
- name: Deploy portfolio-assets
id: assets-deploy
uses: appleboy/lambda-action@v0.1.9
with:
function_name: ${{ env.ASSETS_LAMBDA }}
zip_file: ${{ env.ASSETS_LAMBDA_ZIP_PATH }}
dry_run: false
- name: Deploy portfolio-overview
id: overview-deploy
uses: appleboy/lambda-action@v0.1.9
with:
function_name: ${{ env.OVERVIEW_LAMBDA }}
zip_file: ${{ env.OVERVIEW_LAMBDA_ZIP_PATH }}
dry_run: false
- name: Retrieve the latest version of the Lambdas
id: lambda-latest-version
run: |
assets_latest_version=$(aws lambda list-versions-by-function --function-name ${{ env.ASSETS_LAMBDA }} --query 'Versions[-1].Version' --output text)
echo "assets_latest_version=$assets_latest_version" >> $GITHUB_OUTPUT
overview_latest_version=$(aws lambda list-versions-by-function --function-name ${{ env.OVERVIEW_LAMBDA }} --query 'Versions[-1].Version' --output text)
echo "overview_latest_version=$overview_latest_version" >> $GITHUB_OUTPUT
- name: Update portfolio-assets Lambda Alias
run: |
aws lambda update-alias --function-name ${{ env.ASSETS_LAMBDA }} --name current --function-version ${{ steps.lambda-latest-version.outputs.assets_latest_version }}
- name: Update portfolio-overview Lambda Alias
run: |
aws lambda update-alias --function-name ${{ env.OVERVIEW_LAMBDA }} --name current --function-version ${{ steps.lambda-latest-version.outputs.overview_latest_version }}
- name: Create cache invalidation
run: |
aws apigateway flush-stage-cache --rest-api-id ${{ secrets.STAGING_API_GW_ID }} --stage-name staging