File tree 3 files changed +59
-14
lines changed
3 files changed +59
-14
lines changed Original file line number Diff line number Diff line change 3
3
push :
4
4
branches :
5
5
- v2
6
+
7
+ env :
8
+ REGISTRY : ghcr.io
9
+ IMAGE_NAME : sunday
10
+ IMAGE_NAME_FULL : ghcr.io/nbtca/sunday
11
+
6
12
jobs :
7
13
build :
8
14
runs-on : ubuntu-latest
9
15
steps :
10
16
# 切换分支
11
17
- name : Checkout
12
18
uses : actions/checkout@master
13
- - uses : actions/setup-node@v2
19
+
20
+ - name : Login DockerHub
21
+ uses : docker/login-action@v2
14
22
with :
15
- node-version : " 16"
16
- - run : npm install
17
- - run : npm run build
18
- # Deploy
19
- - name : ssh deploy
20
- uses :
easingthemes/[email protected]
21
- env :
22
- SSH_PRIVATE_KEY : ${{ secrets.ACCESS_TOKEN }}
23
- ARGS : " -avz --delete"
24
- SOURCE : " dist/"
25
- REMOTE_HOST : ${{ secrets.REMOTE_HOST }}
26
- REMOTE_USER : ${{ secrets.REMOTE_USER }}
27
- TARGET : " /home/nbtca/weekend/web/v2"
23
+ registry : ${{ env.REGISTRY }}
24
+ username : ${{ github.actor }}
25
+ password : ${{ secrets.GITHUB_TOKEN }}
26
+
27
+ - name : Build and Push to DockerHub
28
+ uses : docker/build-push-action@v3
29
+ with :
30
+ context : .
31
+ file : ./Dockerfile
32
+ no-cache : true
33
+ # target: deploy
34
+ push : true
35
+ platforms : linux/amd64
36
+ tags : |
37
+ ${{ env.IMAGE_NAME_FULL }}:latest
38
+
39
+ - name : ssh pipelines
40
+ uses : cross-the-world/ssh-pipeline@master
41
+ with :
42
+ host : ${{ secrets.REMOTE_HOST }}
43
+ user : ${{ secrets.REMOTE_USER }}
44
+ key : ${{ secrets.ACCESS_TOKEN }}
45
+ connect_timeout : 10s
46
+ script : |
47
+ cd /home/nbtca/weekend/sunday
48
+ docker-compose stop && docker-compose rm -f
49
+ docker rmi ${{ env.IMAGE_NAME_FULL }}:latest
50
+ docker-compose up -d
Original file line number Diff line number Diff line change
1
+ FROM node as build
2
+
3
+ COPY . /app
4
+ WORKDIR /app
5
+
6
+ RUN npm install &&\
7
+ npm run build
8
+
9
+
10
+ FROM nginx:alpine as deploy
11
+
12
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
13
+ COPY --from=build /app/dist /usr/share/nginx/html
Original file line number Diff line number Diff line change
1
+ server {
2
+ listen 80 ;
3
+ server_name frontend;
4
+
5
+ location / {
6
+ root /usr/share/nginx/html;
7
+ try_files $uri $uri / /index.html;
8
+ }
9
+ }
You can’t perform that action at this time.
0 commit comments