Create deploy.yml #1
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 | |
on: | |
push: | |
branches: | |
- github-actions-for-lambda | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: API Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: API docker build & docker push & lambda update | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest ./api_lambda | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
aws lambda update-function-code --function-name $AWS_LAMBDA_FUNCTION_NAME --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
env: | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_LAMBDA_FUNCTION_NAME: ${{ secrets.API_AWS_LAMBDA_FUNCTION_NAME }} | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.API_AWS_ECR_REPOSITORY_NAME }} | |
- name: ML docker build & docker push & lambda update | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest ./ml_lambda | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
aws lambda update-function-code --function-name $AWS_LAMBDA_FUNCTION_NAME --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:latest | |
env: | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_LAMBDA_FUNCTION_NAME: ${{ secrets.ML_AWS_LAMBDA_FUNCTION_NAME }} | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.ML_AWS_ECR_REPOSITORY_NAME }} |