15
15
workflow_dispatch : # This allows us to trigger the workflow manually
16
16
17
17
jobs :
18
+ dockerhub :
19
+ name : Publish Docker Image(s) to Dockerhub
20
+ runs-on : ubuntu-latest
21
+
22
+ steps :
23
+ - name : Checkout
24
+ uses : actions/checkout@v4
25
+
26
+ - name : Set up QEMU
27
+ uses : docker/setup-qemu-action@v3
28
+
29
+ - name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v3
31
+
32
+ - name : Login to Docker Hub
33
+ uses : docker/login-action@v3
34
+ with :
35
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
36
+ password : ${{ secrets.DOCKERHUB_PASSWORD }}
37
+
38
+ - name : Cache Docker layers for Wiki DB
39
+ uses : actions/cache@v3
40
+ with :
41
+ path : /tmp/.buildx-cache-wiki-db
42
+ key : ${{ runner.os }}-buildx-wiki-db-${{ github.sha }}
43
+ restore-keys : |
44
+ ${{ runner.os }}-buildx-wiki-db-
45
+
46
+ - name : Build & Push Wiki DB
47
+ uses : docker/build-push-action@v5
48
+ with :
49
+ context : ./mysql
50
+ push : true
51
+ tags : ${{ secrets.DOCKERHUB_USERNAME }}/wiki-db:latest
52
+ cache-from : type=local,src=/tmp/.buildx-cache-wiki-db
53
+ cache-to : type=local,dest=/tmp/.buildx-cache-wiki-db-new,mode=max
54
+
55
+ - name : Move Wiki DB cache
56
+ run : |
57
+ rm -rf /tmp/.buildx-cache-wiki-db
58
+ mv /tmp/.buildx-cache-wiki-db-new /tmp/.buildx-cache-wiki-db
59
+
60
+ - name : Cache Docker layers for Wiki Jobs
61
+ uses : actions/cache@v3
62
+ with :
63
+ path : /tmp/.buildx-cache-wiki-jobs
64
+ key : ${{ runner.os }}-buildx-wiki-jobs-${{ github.sha }}
65
+ restore-keys : |
66
+ ${{ runner.os }}-buildx-wiki-jobs-
67
+
68
+ - name : Build & Push Wiki Jobs
69
+ uses : docker/build-push-action@v5
70
+ with :
71
+ context : ./jobs
72
+ push : true
73
+ tags : ${{ secrets.DOCKERHUB_USERNAME }}/wiki-jobs:latest
74
+ cache-from : type=local,src=/tmp/.buildx-cache-wiki-jobs
75
+ cache-to : type=local,dest=/tmp/.buildx-cache-wiki-jobs-new,mode=max
76
+
77
+ - name : Move Wiki Jobs cache
78
+ run : |
79
+ rm -rf /tmp/.buildx-cache-wiki-jobs
80
+ mv /tmp/.buildx-cache-wiki-jobs-new /tmp/.buildx-cache-wiki-jobs
81
+
82
+ - name : Cache Docker layers for Wiki Nginx
83
+ uses : actions/cache@v3
84
+ with :
85
+ path : /tmp/.buildx-cache-wiki-nginx
86
+ key : ${{ runner.os }}-buildx-wiki-nginx-${{ github.sha }}
87
+ restore-keys : |
88
+ ${{ runner.os }}-buildx-wiki-nginx-
89
+
90
+ - name : Build & Push Wiki Nginx
91
+ uses : docker/build-push-action@v5
92
+ with :
93
+ context : ./nginx
94
+ push : true
95
+ tags : ${{ secrets.DOCKERHUB_USERNAME }}/wiki-nginx:latest
96
+ cache-from : type=local,src=/tmp/.buildx-cache-wiki-nginx
97
+ cache-to : type=local,dest=/tmp/.buildx-cache-wiki-nginx-new,mode=max
98
+
99
+ - name : Move Wiki Nginx cache
100
+ run : |
101
+ rm -rf /tmp/.buildx-cache-wiki
102
+ mv /tmp/.buildx-cache-wiki-nginx-new /tmp/.buildx-cache-wiki-nginx
103
+
104
+ - name : Cache Docker layers for Wiki Mediawiki
105
+ uses : actions/cache@v3
106
+ with :
107
+ path : /tmp/.buildx-cache-wiki
108
+ key : ${{ runner.os }}-buildx-wiki-${{ github.sha }}
109
+ restore-keys : |
110
+ ${{ runner.os }}-buildx-wiki-
111
+
112
+ - name : Build & Push Wiki Mediawiki
113
+ uses : docker/build-push-action@v5
114
+ with :
115
+ context : ./mediawiki
116
+ push : true
117
+ tags : ${{ secrets.DOCKERHUB_USERNAME }}/wiki:latest
118
+ cache-from : type=local,src=/tmp/.buildx-cache-wiki
119
+ cache-to : type=local,dest=/tmp/.buildx-cache-wiki-new,mode=max
120
+
121
+ - name : Move Wiki Mediawiki cache
122
+ run : |
123
+ rm -rf /tmp/.buildx-cache-wiki-nginx
124
+ mv /tmp/.buildx-cache-wiki-new /tmp/.buildx-cache-wiki
125
+
18
126
push :
19
- name : Push Stage
127
+ name : Push Code Stage
128
+ needs : dockerhub
20
129
runs-on : ubuntu-latest
21
130
22
131
steps :
@@ -36,13 +145,13 @@ jobs:
36
145
sudo git fetch origin
37
146
sudo git reset --hard origin/master
38
147
39
- build :
40
- name : Build Stage
148
+ pull :
149
+ name : Pull Image Stage
41
150
needs : push
42
151
runs-on : ubuntu-latest
43
152
44
153
steps :
45
- - name : Build the latest container (s)
154
+ - name : Pull the latest images (s)
46
155
uses : appleboy/ssh-action@master
47
156
env :
48
157
PROJECT_DIR : ${{ secrets.PROJECT_DIR }}
@@ -56,11 +165,11 @@ jobs:
56
165
script_stop : true
57
166
script : |
58
167
cd "${PROJECT_DIR}/"
59
- sudo docker compose -f docker-compose.prod.yml build
168
+ sudo docker compose -f docker-compose.prod.yml pull
60
169
61
170
deploy :
62
171
name : Deploy Stage
63
- needs : [push, build]
172
+ needs : pull
64
173
runs-on : ubuntu-latest
65
174
66
175
steps :
0 commit comments