Skip to content

eu2525 is testing out GitHub Actions ๐Ÿš€ #5

eu2525 is testing out GitHub Actions ๐Ÿš€

eu2525 is testing out GitHub Actions ๐Ÿš€ #5

Workflow file for this run

name: Build and Deploy Dittodining-Server to ECS
run-name: ${{ github.actor }} is testing out GitHub Actions ๐Ÿš€
# Github Actsion๊ฐ€ Trigger ๋˜๋Š” ์กฐ๊ฑด
on:
push:
#Test์šฉ์œผ๋กœ ํ•ด๋‹น ๋ธŒ๋žœ์น˜์—์„œ ๋ฐ”๋€ ๊ฒŒ ์žˆ์œผ๋ฉด Deploy ํ•˜๊ฒŒ๋” ์ง„ํ–‰
branches:
- feat/cd-pipeline-with-github-actions
jobs:
deploy:
name: Deploy to ECS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: dittodining
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: dittodining
image: ${{ steps.build-image.outputs.image }}