Skip to content

Commit

Permalink
Merge pull request #127 from ShallWeProject/feat/125-github-action-ci/cd
Browse files Browse the repository at this point in the history
GitHub Action CI/CD 구축
  • Loading branch information
leeseunghakhello authored Sep 26, 2023
2 parents c44a991 + 01b5e3b commit 31f58ce
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 13 deletions.
68 changes: 66 additions & 2 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,78 @@ jobs:
CI-CD:
runs-on: ubuntu-latest

## jdk setting
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

## gradle caching
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## create application-dev.yml
- name: make application-database.yml
if: contains(github.ref, 'develop')
run: |
cd ./src/main/resources
touch ./application-databaase.yml
echo "${{ secrets.PROPERTIES_DEV }}" > ./application-database.yml
shell: bash

## gradle build
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
run: ./gradlew build -x test

## docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'develop')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}/shallwe-dev .
docker push ${{ secrets.DOCKER_REPO }}/shallwe-dev
## docker build & push to develop
## deploy to develop
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'dev')
with:
arguments: build
host: ${{ secrets.HOST_DEV }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: 22
#key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}/shallwe-dev
docker-compose up -d
docker image prune -f
## time
current-time:
needs: CI-CD
runs-on: ubuntu-latest
steps:
- name: Get Current Time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH:mm:ss
utcOffset: "+09:00" # 기준이 UTC이기 때문에 한국시간인 KST를 맞추기 위해 +9시간 추가

- name: Print Current Time
run: echo "Current Time=${{steps.current-time.outputs.formattedTime}}" # current-time 에서 지정한 포맷대로 현재 시간 출력
shell: bash
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM openjdk:17-jdk

# JAR_FILE 변수 정의
ARG JAR_FILE=./build/libs/ShallWe-0.0.1-SNAPSHOT.jar

# JAR 파일 메인 디렉터리에 복사
COPY ${JAR_FILE} app.jar

# 시스템 진입점 정의
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"]
#FROM openjdk:11-jdk
#
## JAR_FILE 변수 정의
#ARG JAR_FILE=./build/libs/ShallWe-0.0.1-SNAPSHOT.jar
#
## JAR 파일 메인 디렉터리에 복사
#COPY ${JAR_FILE} app.jar
#
## 시스템 진입점 정의
#ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar"]
5 changes: 5 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:17-jdk
EXPOSE 8080
ARG JAR_FILE=/build/libs/ShallweProject_Server-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","-Djasypt.encryptor.password=${JASYPT_PASSWORD}","-Dspring.profiles.active=dev","/app.jar"]
2 changes: 1 addition & 1 deletion src/main/java/com/shallwe/ShallWeApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.context.annotation.PropertySource;

@SpringBootApplication
@PropertySource(value = {"classpath:database/application-database.yml"}, factory = YamlPropertySourceFactory.class)
@PropertySource(value = {"classpath:database/application-dev.yml"}, factory = YamlPropertySourceFactory.class)
@PropertySource(value = {"classpath:cloud/application-s3file.yml"}, factory = YamlPropertySourceFactory.class)
@PropertySource(value = {"classpath:cloud/application-navercloud.yml"}, factory = YamlPropertySourceFactory.class)
@PropertySource(value = { "classpath:oauth2/application-oauth2.yml" }, factory = YamlPropertySourceFactory.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import static com.shallwe.domain.experiencegift.domain.QExperienceGift.experienceGift;

//import com.shallwe.domain.experiencegift.domain.QExperienceGift.ExperienceGift;


@RequiredArgsConstructor
@Repository
public class ExperienceGiftQuerydslRepositoryImpl implements ExperienceGiftQuerydslRepository {
Expand Down

0 comments on commit 31f58ce

Please sign in to comment.