-
Notifications
You must be signed in to change notification settings - Fork 2
114 lines (88 loc) · 2.99 KB
/
deploy.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: deploy
# active when push tag v0.0.1
on:
push:
tags:
- 'v*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
# spring jar build ######################################
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: "11"
distribution: "adopt"
cache: gradle
check-latest: true
- name: Grant execute permission for gradlew
working-directory: ./spring.stock
run: chmod +x gradlew
- name: Build with Gradle
working-directory: ./spring.stock
run: ./gradlew build
# spring docker build ######################################
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Docker meta
id: meta1
uses: docker/metadata-action@v4
with:
images: ttop324/spring.stock
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: ./spring.stock
file: ./spring.stock/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta1.outputs.tags }}
labels: ${{ steps.meta1.outputs.labels }}
# nuxt docker build ######################################
-
name: Docker meta
id: meta2
uses: docker/metadata-action@v4
with:
images: ttop324/nuxt.stock
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: ./nuxt.stock
file: ./nuxt.stock/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta2.outputs.tags }}
labels: ${{ steps.meta2.outputs.labels }}
# aws deploy ######################################
- name: copy source via ssh key
uses: burnett01/rsync-deployments@5.2
with:
switches: -avzr
path: "./deploy/"
remote_path: "~/"
remote_host: ${{ secrets.HOST }}
remote_user: ${{ secrets.USERNAME }}
remote_key: ${{ secrets.KEY }}
remote_port: ${{ secrets.PORT }}
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
sudo docker stack deploy -c docker-compose.yml web
# only updated images
# sudo docker stack deploy -c docker-compose.yml --resolve-image=changed web