-
Notifications
You must be signed in to change notification settings - Fork 1
39 lines (33 loc) · 1.09 KB
/
CD.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
38
39
name: CD Workflow
on:
push:
branches:
- dev
jobs:
docker:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Image Build
run: docker build -t ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} -f dockerfile.prod .
- name: Login DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PW }}
- name: DockerHub Push
run: docker push ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}
- name: EC2 Login
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST_NAME }}
username: ${{secrets.USER_NAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker-compose down
docker image prune
docker rm $(docker ps -a -q)
docker pull ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}
docker-compose up -d