-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (78 loc) · 3.21 KB
/
deploy_dev.yaml
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
on:
push:
branches:
- develop
paths:
- docker-compose-backend.yml
- Dockerfile
- gradle.properties
- gradlew
- gradlew.bat
- build.gradle.kts
- settings.gradle.kts
- src/**
- gradle/**
- .github/workflows/deploy.yaml
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3.12.0
with:
java-version: '21'
distribution: 'temurin'
- run: ./gradlew clean bootJar -x test
- name: Log in to the Container Registry
uses: docker/login-action@v2.2.0
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build and push Docker image
uses: docker/build-push-action@v4.1.1
with:
context: .
push: true
build-args: |
PROFILE=dev
tags: |
ghcr.io/wafflestudio/csereal-server/server_image:dev
ghcr.io/wafflestudio/csereal-server/server_image:${{github.sha}}
- name: Create .env file
run: |
echo "PROFILE=dev" > .env
echo "MYSQL_ROOT_PASSWORD=${{secrets.MYSQL_ROOT_PASSWORD}}" >> .env
echo "MYSQL_USER=${{secrets.MYSQL_USER}}" >> .env
echo "MYSQL_PASSWORD=${{secrets.MYSQL_PASSWORD}}" >> .env
echo "MYSQL_DATABASE=${{secrets.MYSQL_DATABASE}}" >> .env
echo "OIDC_CLIENT_SECRET_DEV=${{secrets.OIDC_CLIENT_SECRET_DEV}}" >> .env
echo "URL=${{secrets.URL_DEV}}" >> .env
# echo "SLACK_TOKEN=${{secrets.SLACK_TOKEN}}" >> .env
# echo "SLACK_CHANNEL=${{secrets.SLACK_CHANNEL}}" >> .env
- name: SCP Command to Transfer Files
uses: appleboy/scp-action@v0.1.4
with:
host: ${{secrets.SSH_HOST_DEV}}
username: ${{secrets.SSH_USER}}
key: ${{secrets.SSH_KEY}}
source: "docker-compose-backend.yml, .env"
target: "~/app"
overwrite: true
- name: SSH Remote Commands
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{secrets.SSH_HOST_DEV}}
username: ${{secrets.SSH_USER}}
key: ${{secrets.SSH_KEY}}
script: |
cd ~/app
source .env
docker-compose -f docker-compose-backend.yml down
docker-compose -f docker-compose-backend.yml pull
docker-compose -f docker-compose-backend.yml up -d