-
Notifications
You must be signed in to change notification settings - Fork 2
44 lines (40 loc) · 1.28 KB
/
docker.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
name: Docker Build
# 1.1.0
# klsafjdl
# 2023-04-27-12-00-klsafjdl
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Build Docker image
run: docker build -t dmitrydorofeev/godeploy:${GITHUB_SHA::8} .
- name: Push the image
run: docker push dmitrydorofeev/godeploy:${GITHUB_SHA::8}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: pull docker image
uses: appleboy/ssh-action@master
with:
envs: GITHUB_SHA
host: 37.139.41.28
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: sudo docker pull dmitrydorofeev/godeploy:${GITHUB_SHA::8}
- name: deploy docker image
uses: appleboy/ssh-action@master
with:
envs: GITHUB_SHA
host: 37.139.41.28
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker rm -f $(sudo docker ps -aq)
sudo docker run -e VERSION=${GITHUB_SHA::8} -d -p 8080:8080 dmitrydorofeev/godeploy:${GITHUB_SHA::8}