deploy #18
Workflow file for this run
This file contains 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 | |
permissions: | |
id-token: write # for aws role | |
contents: read | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
lambda: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup Chalk | |
uses: crashappsec/setup-chalk-action@main | |
with: | |
connect: true | |
- name: Assume AWS Role | |
id: role | |
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 #v2 | |
with: | |
aws-region: us-east-1 | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
role-session-name: GithubDeploy | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #v2.0.1 | |
with: | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 #v2.0.1 | |
with: | |
aws-region: us-west-2 | |
- name: Push | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
provenance: true | |
sbom: true | |
context: . | |
tags: | | |
${{ steps.id.outputs.aws-account-id }}.dkr.ecr.us-east-1.amazonaws.com/${{ secrets.AWS_ECR_IMAGE }} | |
${{ steps.id.outputs.aws-account-id }}.dkr.ecr.us-west-2.amazonaws.com/${{ secrets.AWS_ECR_IMAGE }} | |
- name: Redeploy Lambda | |
run: | | |
aws lambda update-function-code \ | |
--region us-east-1 \ | |
--function-name ${{ secrets.AWS_LAMBDA_NAME }} \ | |
--image-uri ${{ secrets.AWS_ECR_IMAGE }}:latest | |
aws lambda update-function-code \ | |
--region us-west-2 \ | |
--function-name ${{ secrets.AWS_LAMBDA_NAME }} \ | |
--image-uri ${{ secrets.AWS_ECR_IMAGE }}:latest | |
aws lambda wait function-updated \ | |
--region us-east-1 \ | |
--function-name ${{ secrets.AWS_LAMBDA_NAME }} | |
aws lambda wait function-updated \ | |
--region us-west-2 \ | |
--function-name ${{ secrets.AWS_LAMBDA_NAME }} | |
- name: Invoke Lambda | |
run: | | |
aws lambda invoke \ | |
--region us-east-1 \ | |
--function-name=${{ secrets.AWS_LAMBDA_NAME }} \ | |
/dev/stdout | |
aws lambda invoke \ | |
--region us-west-2 \ | |
--function-name=${{ secrets.AWS_LAMBDA_NAME }} \ | |
/dev/stdout |