-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (79 loc) · 2.82 KB
/
docker-cd.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
name: develop CD
on:
push:
branches: [ develop ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code.
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: '20.x'
- name: Install yarn
run: npm install -g yarn
- name: Build with yarn
run: |
yarn install
yarn workspace frontend build
yarn workspace backend build
- name: make BE .env
run: |
echo "${{ secrets.BE_ENV }}" > .env
- name: send BE .env
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
source: .env
target: /dandi
overwrite: true
- name: make FE .env
run: |
cd frontend
echo "${{ secrets.FE_ENV }}" > .env
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: make docker images
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }} -f ./Dockerfile.was .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }}
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }} -f ./Dockerfile.front .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }}
- name: make docker-compose files
run: |
sed -i "s/GITHUB_SHA/${{ github.sha }}/g" ./docker/docker-compose.blue.yml
sed -i "s/GITHUB_SHA/${{ github.sha }}/g" ./docker/docker-compose.green.yml
- name: send files & deploy script
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
source: "nginx/dandi-blue.conf,nginx/dandi-green.conf,docker/docker-compose.blue.yml,docker/docker-compose.green.yml,docker/deploy.sh"
target: /dandi
overwrite: true
- name: deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }}
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }}
cd /dandi/docker
chmod +x deploy.sh
./deploy.sh