forked from UMC-Edison/Edison-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (88 loc) Β· 3.63 KB
/
Copy pathdev_deploy.yml
File metadata and controls
112 lines (88 loc) Β· 3.63 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Edison Spring CI/CD
on:
push:
branches: [ main, develop ]
workflow_dispatch:
env:
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/edison-spring
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Create application.properties
run: |
mkdir -p ./project/src/main/resources/
cat > ./project/src/main/resources/application.properties << EOF
spring.jpa.hibernate.ddl-auto=update
server.forward-headers-strategy=framework
spring.datasource.url=\${SPRING_DATASOURCE_URL}
spring.datasource.username=\${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=\${SPRING_DATASOURCE_PASSWORD}
spring.data.redis.host=\${SPRING_DATA_REDIS_HOST:localhost}
spring.data.redis.port=\${SPRING_DATA_REDIS_PORT:6379}
spring.data.redis.password=\${SPRING_DATA_REDIS_PASSWORD}
jwt.secret=\${JWT_SECRET}
jwt.access-token-expiration=\${JWT_ACCESS_TOKEN_EXPIRATION:3600000}
jwt.refresh-token-expiration=\${JWT_REFRESH_TOKEN_EXPIRATION:604800000}
spring.security.oauth2.client.registration.google.client-id=\${SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_ID}
spring.security.oauth2.client.registration.google.client-secret=\${SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_SECRET}
openai.secret_key=\${OPENAI_SECRET_KEY}
cloud.aws.credentials.access-key=\${CLOUD_AWS_CREDENTIALS_ACCESS_KEY}
cloud.aws.credentials.secret-key=\${CLOUD_AWS_CREDENTIALS_SECRET_KEY}
cloud.aws.region.static=\${CLOUD_AWS_REGION_STATIC:ap-northeast-2}
cloud.aws.s3.bucket=\${CLOUD_AWS_S3_BUCKET}
management.endpoints.web.exposure.include=health
management.endpoint.health.show-details=always
EOF
- name: Grant execute permission for gradlew
run: chmod +x project/gradlew
- name: Build with Gradle
run: cd project && ./gradlew clean build -x test --no-daemon
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=sha,prefix=
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/edison-infra
cat > .env << 'ENVEOF'
${{ secrets.ENV_FILE }}
ENVEOF
sed -i 's/^SPRING_TAG=.*/SPRING_TAG=${{ github.sha }}/' .env
./deploy.sh spring ${{ github.sha }}