Skip to content
Closed

test #61

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/develop_build_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Deploy to Develop

on:
pull_request:
branches:
- develop
push:
branches:
- develop

env:
DOCKERHUB_USERNAME: ht3064
DOCKERHUB_IMAGE_NAME: syncfit-server

jobs:
build-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Extract metadata for Docker
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}
tags: |
type=sha,prefix=

- name: Build and Push Docker image
uses: docker/build-push-action@v4.1.1
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}

- name: Copy docker-compose.yml to EC2
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
source: docker-compose.yml
target: /home/ubuntu/

- name: Deploy to EC2
uses: appleboy/ssh-action@master
env:
IMAGE_FULL_URL: ${{ steps.metadata.outputs.tags }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
envs: IMAGE_FULL_URL, DOCKERHUB_IMAGE_NAME
script: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${{ env.DOCKERHUB_USERNAME }}" --password-stdin
docker compose up -d
docker image prune -a -f
2 changes: 2 additions & 0 deletions src/main/resources/application-datasource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ spring:
properties:
hibernate:
default_batch_fetch_size: 100
hibernate:
ddl-auto: create
logging:
level:
org.hibernate.SQL: debug
1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
spring:
profiles:
active: "local"
group:
local: "local"
dev: "dev"
Expand Down