-
Notifications
You must be signed in to change notification settings - Fork 4
65 lines (58 loc) · 2.79 KB
/
backend-dev-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
on:
pull_request:
branches:
- release-be-develop
types:
- closed
jobs:
deploy:
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'be') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: 'backend/.nvmrc'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- name: Install dependencies
run: |
cd backend
yarn install --frozen-lockfile
- name: Build Docker image
run: docker build -t ${{ secrets.NCP_DOCKER_REGISTORY }}/snap-point:latest ./backend
- name: Login to NCP container registory
run: docker login ${{ secrets.NCP_DOCKER_REGISTORY }} -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }}
- name: Push Docker image to Docker Hub
run: docker push ${{ secrets.NCP_DOCKER_REGISTORY }}/snap-point:latest
- name: SSH into Ubuntu server and pull the latest image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASSWORD }}
key: ${{ secrets.SSH_PEM_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker login ${{ secrets.NCP_DOCKER_REGISTORY }} -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }}
docker stop snap-point-container || true
docker rm snap-point-container || true
docker image prune -f
docker pull ${{ secrets.NCP_DOCKER_REGISTORY }}/snap-point:latest
docker run -d -p 3000:3000 --name snap-point-container \
-e DATABASE_URL="${{ secrets.DATABASE_URL }}" \
-e SHADOW_DATABASE_URL="${{ secrets.SHADOW_DATABASE_URL }}" \
-e NCP_DOCKER_REGISTORY="${{ secrets.NCP_DOCKER_REGISTORY }}" \
-e BUCKET_URL="${{ secrets.BUCKET_URL }}" \
-e NCP_ACCESS_KEY="${{ secrets.NCP_ACCESS_KEY }}" \
-e NCP_SECRET_KEY="${{ secrets.NCP_SECRET_KEY }}" \
-e NCP_BUCKET_ENDPOINT="${{ secrets.NCP_BUCKET_ENDPOINT }}" \
-e NCP_BUCKET_NAME="${{ secrets.NCP_BUCKET_NAME }}" \
-e NCP_BUCKET_REGION="${{ secrets.NCP_BUCKET_REGION }}" \
-e JWT_ACCESS_SECRET="${{ secrets.JWT_ACCESS_SECRET }}" \
-e JWT_REFRESH_SECRET="${{ secrets.JWT_REFRESH_SECRET }}" \
-e JWT_ACCESS_EXPIRATION_TIME="${{ secrets.JWT_ACCESS_EXPIRATION_TIME }}" \
-e JWT_REFRESH_EXPIRATION_TIME="${{ secrets.JWT_REFRESH_EXPIRATION_TIME }}" \
${{ secrets.NCP_DOCKER_REGISTORY }}/snap-point:latest