Skip to content

Commit c94717b

Browse files
committed
2 parents 62e129d + 3a9ec7b commit c94717b

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

.github/workflows/aws.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Didacto-core dev CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 코드 체크아웃
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
17+
# JDK 설치
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 17
22+
23+
- name: make application.yml
24+
run: |
25+
mkdir -p ./src/main/resources
26+
cd ./src/main/resources
27+
touch ./application.yml
28+
echo "${{ secrets.APPLICATION_PROD }}" > ./application.yml
29+
30+
# Gradle Build
31+
- name: Build with Gradle
32+
run: ./gradlew build
33+
34+
# DockerHub 로그인
35+
- name: Login to DockerHub
36+
uses: docker/login-action@v1
37+
with:
38+
username: ${{ secrets.DOCKER_USERNAME }}
39+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
40+
41+
# DockerHub Push
42+
- name: Build and Push Docker image
43+
run: |
44+
docker build -t ${{ secrets.DOCKER_USERNAME }}/didacto-app-dev .
45+
docker push ${{ secrets.DOCKER_USERNAME }}/didacto-app-dev
46+
47+
48+
deploy:
49+
runs-on: ubuntu-latest
50+
needs: build
51+
52+
steps:
53+
# AWS 배포
54+
- name: SSH to EC2 and deploy
55+
uses: appleboy/[email protected]
56+
with:
57+
host: ${{ secrets.EC2_HOST }}
58+
username: ${{ secrets.EC2_USER }}
59+
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
60+
script: |
61+
cd didacto-testserver
62+
sudo docker-compose stop
63+
sudo docker-compose rm -f
64+
sudo docker rmi sjh9708/didacto-app-dev:latest
65+
sudo docker-compose up -d

.github/workflows/gradle.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7+
8+
name: Java CI with Gradle
9+
10+
on:
11+
push:
12+
branches: [ "main" ]
13+
pull_request:
14+
branches: [ "main" ]
15+
16+
jobs:
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up JDK 17
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '17'
29+
distribution: 'temurin'
30+
31+
- name: make application.yml
32+
run: |
33+
mkdir -p ./src/main/resources
34+
cd ./src/main/resources
35+
touch ./application.yml
36+
echo "${{ secrets.APPLICATION_PROD }}" > ./application.yml
37+
38+
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
39+
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
42+
43+
- name: Build with Gradle Wrapper
44+
run: ./gradlew build
45+
46+
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
47+
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
48+
#
49+
# - name: Setup Gradle
50+
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
51+
# with:
52+
# gradle-version: '8.9'
53+
#
54+
# - name: Build with Gradle 8.9
55+
# run: gradle build
56+
57+
dependency-submission:
58+
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
- name: Set up JDK 17
66+
uses: actions/setup-java@v4
67+
with:
68+
java-version: '17'
69+
distribution: 'temurin'
70+
71+
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
72+
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
73+
- name: Generate and submit dependency graph
74+
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM amazoncorretto:17
2+
# FROM openjdk:17-jdk
3+
ARG JAR_FILE=build/libs/*.jar
4+
5+
COPY ${JAR_FILE} my-project.jar
6+
# COPY build/libs/*.jar my-project.jar
7+
ENTRYPOINT ["java","-jar","/my-project.jar"]
8+
9+
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

0 commit comments

Comments
 (0)