feat: migrate lambda deployment #42
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 Backend to Preview ECS | |
on: | |
push: | |
branches: ["main"] | |
paths: | |
- "server/**" | |
pull_request: | |
branches: [ "main" ] | |
env: | |
AWS_REGION: ap-northeast-1 | |
ECR_REPOSITORY: petercat-lambda | |
ECR_REGISTRY: 654654285942.dkr.ecr.ap-northeast-1.amazonaws.com | |
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 | |
environment: production | |
strategy: | |
fail-fast: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::654654285942:role/Github-OIDC | |
audience: sts.amazonaws.com | |
aws-region: ${{ env.AWS_REGION }} | |
# Build inside Docker containers | |
- run: sam build --use-container --config-file .aws/petercat-preview.toml | |
# Prevent prompts and failure when the stack is unchanged | |
- run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --config-file .aws/petercat-preview.toml | |
# Output deployment result | |
- name: Retrieve Deployment output | |
id: sam-output | |
run: echo ::set-output name=stack_output::$(sam list stack-outputs --stack-name petercat-api-preview --output table) | |
- name: Find Comment | |
uses: peter-evans/find-comment@v3 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Build output | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Build output | |
${{ steps.sam-output.outputs.stack_output }} | |
edit-mode: replace |