-
Notifications
You must be signed in to change notification settings - Fork 4
73 lines (64 loc) ยท 1.95 KB
/
main.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
name: continuous-deploy-by-docker
on:
push:
branches:
- main
jobs:
build-push-pull-down_up:
runs-on: ubuntu-latest
steps:
- name: checkout the repo
uses: actions/checkout@v2
- name: create root env file
run: |
rm .env
touch .env
echo "${{ secrets.ROOT_ENV }}" > .env
- name: create client env file
run: |
cd client
touch .env.production
echo "${{ secrets.CLIENT_ENV }}" > .env.production
- name: create env file
run: |
cd server
touch .env.production
echo "${{ secrets.SERVER_ENV }}" > .env.production
- name: ghcr login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.USERNAME }}
password: ${{ secrets.ACCESS_TOKEN }}
- name: build image
run: docker compose build
- name: push image
run: docker compose push
- name: deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/Web11-Donggle
git remote update
git checkout origin/main
git reset --hard
rm .env
touch .env
echo "${{ secrets.ROOT_ENV }}" > .env
cd ./client
rm .env.production
touch .env.production
echo "${{ secrets.CLIENT_ENV }}" > .env.production
cd ../server
rm .env.production
touch .env.production
echo "${{ secrets.SERVER_ENV }}" > .env.production
cd ..
docker login ghcr.io/ -u ${{ secrets.USERNAME }} -p ${{ secrets.ACCESS_TOKEN }}
docker-compose pull
docker-compose down
docker-compose up -d