

# GitHub Actions를 사용하여 Lambda 함수 배포
<a name="deploying-github-actions"></a>

코드 또는 구성 변경 사항을 리포지토리에 푸시할 때 [GitHub Actions](https://github.com/features/actions)를 사용하여 Lambda 함수를 자동으로 배포할 수 있습니다. [Lambda 함수 배포](https://github.com/aws-actions/aws-lambda-deploy) 작업은 수동 배포 단계의 복잡성을 줄여주는 선언적이고 간단한 YAML 인터페이스를 제공합니다.

## 워크플로 예제
<a name="deploying-github-actions-example"></a>

자동 Lambda 함수 배포를 구성하려면 리포지토리의 `.github/workflows/` 디렉터리에 워크플로 파일을 생성합니다.

**Example Lambda 배포를 위한 GitHub Actions 워크플로**  

```
name: Deploy AWS Lambda

on:
  push:
    branches: 
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write # Required for OIDC authentication
      contents: read  # Required to check out the repository
    steps:
      - uses: actions/checkout@v4
      
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/GitHubActionRole
          aws-region: us-east-1
      
      - name: Deploy Lambda Function
        uses: aws-actions/aws-lambda-deploy@v1
        with:
          function-name: my-lambda-function
          code-artifacts-dir: ./dist
```

이 워크플로는 `main` 브랜치에 변경 사항을 푸시할 때 실행됩니다. 리포지토리를 확인하고, OpenID Connect(OIDC)를 사용하여 AWS 자격 증명을 구성하고, `./dist` 디렉터리의 코드를 사용하여 함수를 배포합니다.

함수 구성 업데이트, S3 버킷을 통한 배포, 모의 실행 검증을 포함한 추가 예제는 [Deploy Lambda Function README](https://github.com/aws-actions/aws-lambda-deploy)를 참조하세요.

## 추가 리소스
<a name="deploying-github-actions-resources"></a>
+ [Configure AWS Credentials GitHub Action](https://github.com/aws-actions/configure-aws-credentials)
+ [AWS에서 OpenID Connect 구성](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)