Skip to content

Commit

Permalink
feat : GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
NameIsUser06 committed Dec 27, 2023
1 parent a8f62d8 commit aa5ef83
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Java CI/CD with Gradle

on:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# 1. Java 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# 2. Spring Boot 애플리케이션 빌드
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean bootJar

# 3. Docker 이미지 빌드
- name: docker image build
run: docker buildx build --platform=linux/arm64 -t ${{ secrets.DOCKERHUB_USERNAME }}/attachit:latest .

# 4. Dockerhub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# 5. Dockerhub push
- name: docker hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/attachit:latest

- name: Connect to WAS & Execute Application
uses: appleboy/[email protected]
with:
host: ${{ secrets.WAS_HOST }}
username: ${{ secrets.WAS_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.WAS_SSH_PORT }}
script: |
cd ~/attachit
docker-compose down
docker-compose pull
docker-compose up -d
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:17-oracle

WORKDIR /app

ARG JAR_FILE=build/libs/*.jar

COPY ${JAR_FILE} app.jar

EXPOSE 8082

CMD ["java", "-jar", "app.jar"]

0 comments on commit aa5ef83

Please sign in to comment.