Skip to content

refactor(deploy): enhance deployment workflows and documentation #3

refactor(deploy): enhance deployment workflows and documentation

refactor(deploy): enhance deployment workflows and documentation #3

Workflow file for this run

name: Deploy API to Lambda
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
branches:
- main
paths:
- 'api/**'
- '.github/workflows/deploy-api.yml'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: devsper-registry-api
IMAGE_TAG: ${{ github.sha }}
run: |
cd api
docker buildx build --provenance=false --platform linux/arm64 \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
-f Dockerfile.lambda \
--push .
- name: Update Lambda function
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: devsper-registry-api
IMAGE_TAG: ${{ github.sha }}
run: |
aws lambda update-function-code \
--function-name devsper-registry-api \
--image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Wait for function update to complete
run: |
aws lambda wait function-updated-v2 --function-name devsper-registry-api