-
Notifications
You must be signed in to change notification settings - Fork 4
45 lines (39 loc) · 1.13 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
38
39
40
41
42
43
44
45
name: Build and Push Docker image
on:
push:
branches:
- main
- jh
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: newnyup319/greedot-backend:latest
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AZURE_HOST }}
username: ${{ secrets.AZURE_USERNAME }}
key: ${{ secrets.AZURE_KEY }}
script: |
sudo bash /home/gosu/mainserver/update-docker.sh
- name: Cleanup Dangling Docker Images
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AZURE_HOST }}
username: ${{ secrets.AZURE_USERNAME }}
key: ${{ secrets.AZURE_KEY }}
script: |
sudo docker images -q -f dangling=true | sudo xargs docker rmi