-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (35 loc) · 1.28 KB
/
docker-build-and-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Docker Build and Push
on:
push:
tags:
- 'api-release-*.*.*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract version from tag
run: |
echo "BUILD_IMAGE_TAG=$(echo $GITHUB_REF_NAME | awk -F '-' '{ print $3 }')" >> $GITHUB_ENV
id: extract_version
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag platput/filmemo:${{ env.BUILD_IMAGE_TAG }}
docker tag platput/filmemo:${{ env.BUILD_IMAGE_TAG }} platput/filmemo:latest
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push the Docker image
run: |
docker push platput/filmemo:${{ env.BUILD_IMAGE_TAG }}
docker push platput/filmemo:latest
- name: Update ECS task definition with latest image
uses: imehedi/actions-awscli-v2@latest
with:
args: ecs update-service --cluster default --service f12 --task-definition filmemoapi --force-new-deployment
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-1