Skip to content

🔧 Updated first issue date #10

🔧 Updated first issue date

🔧 Updated first issue date #10

Workflow file for this run

name: Deploy code to AWS lambda
on:
push:
branches: [ main ]
tags:
- "v*.*.*"
pull_request:
branches: [ main ]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v4
- name: Load cached $HOME/.local
uses: actions/cache@v3
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/deploy.yml') }}
- name: Install poetry & poetry export
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
- name: Export requirements.txt
run: poetry export -f requirements.txt --output requirements.txt --without-hashes
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.IAM_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: "eu-west-3"
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build --platform linux/amd64 -t $ECR_REGISTRY/inews:latest .
docker push $ECR_REGISTRY/inews:latest
- name: Update lambda code
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
aws lambda update-function-code \
--function-name inews \
--image-uri $ECR_REGISTRY/inews:latest > /dev/null