-
Notifications
You must be signed in to change notification settings - Fork 2
93 lines (91 loc) · 3.3 KB
/
deploy-test.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
on:
push:
branches: [test]
jobs:
build:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build and release to DockerHub
env: # 환경변수로 값을 지정하여 사용할 수 있습니다.
REPO: kth2624
LAYER_NAME: together-test
run: |
docker build -t $LAYER_NAME .
docker tag $LAYER_NAME:latest $REPO/$LAYER_NAME:latest
docker push $REPO/$LAYER_NAME:latest
SSH:
needs: build
name: deploy
runs-on: ubuntu-latest
environment: together42
steps:
- uses: actions/checkout@v2
- name: Run scripts in server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.KYU_HOST }}
username: ubuntu
key: ${{ secrets.AWS_KYU_KEY }}
port: 22
script: |
mkdir -p test_server
echo "DB_DATABASE=${{ secrets.TEST_DATABASE }}
DB_USER=${{ secrets.TEST_DATABASE_USER }}
DB_PASSWORD=${{ secrets.TEST_DATABASE_PASSWORD }}
DB_HOST=${{ secrets.TEST_DB_HOST }}
DB_PORT=${{ secrets.TEST_DB_PORT }}
JWT_SECRET=${{ secrets.JWT_SECRET }}
JWT_EXPIRES_SEC=${{ secrets.JWT_EXPIRES_SEC }}
BCRYPT_SALT_ROUNDS=${{ secrets.BCRYPT_SALT_ROUNDS }}
HOST_PORT=${{ secrets.TEST_PORT }}
NAVER_ID=${{ secrets.NAVER_ID }}
NAVER_PW=${{ secrets.NAVER_PW }}
ACCESS_KEY_ID=${{ secrets.ACCESS_KEY_ID }}
SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS_KEY }}
BUCKET=${{ secrets.BUCKET }}
REGION=${{ secrets.AWS_REGION }}
DOCKER_IMAGE=${{ secrets.DOCKER_IMAGE }}
BOT_USER_OAUTH_ACCESS_TOKEN=${{ secrets.BOT_TEST_USER_OAUTH_ACCESS_TOKEN }}
SWAGGER_USER=${{ secrets.SWAGGER_USER }}
SWAGGER_PASSWORD=${{ secrets.SWAGGER_PASSWORD }}
SLACK_JIP=${{ secrets.SLACK_TEST_JIP }}
SLACK_TKIM=${{ secrets.SLACK_TKIM }}
SLACK_YWEE=${{ secrets.SLACK_YWEE }}
OPENAPI_HOLIDAY_KEY=${{ secrets.OPENAPI_HOLIDAY_KEY }}
BACKEND_TEST_HOST=dev.together.42jip.net" > ./test_server/.env
echo "start docker"
docker stop backend_test || true
docker rm backend_test || true
docker rmi ${{ secrets.DOCKER_IMAGE }} || true
cat <<EOF > ./test_server/docker-compose.yaml
version: "3"
services:
backend:
container_name: backend_test
image: ${{ secrets.DOCKER_IMAGE }}
restart: always
volumes:
- ./logs:/logs
ports:
- 9999:9999
env_file: .env
networks:
- test_backend
networks:
test_backend:
external: true
EOF
cd test_server && docker-compose up -d
docker image prune -f