diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..600e9c5 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,34 @@ +name: CD + +on: + workflow_run: + workflows: [ "CI" ] + types: + - completed + branches: + - main + +jobs: + deploy: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to DockerHub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Extract Docker image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: dungbik/flipnote-reaction + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..66b6fa3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Run tests + run: ./gradlew test + + dependency-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run dependency check + uses: dependency-check/Dependency-Check_Action@main + with: + project: 'FlipNote-Reaction' + path: '.' + format: 'HTML' + + - name: Upload dependency check report + uses: actions/upload-artifact@v4 + if: always() + with: + name: dependency-check-report + path: reports/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b5f80a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM gradle:8-jdk21 AS build +WORKDIR /app + +COPY build.gradle.kts settings.gradle.kts ./ +COPY src ./src + +RUN gradle bootJar --no-daemon + +FROM eclipse-temurin:21-jre +WORKDIR /app + +ENV TZ=Asia/Seoul +RUN apt-get update \ + && apt-get install -y tzdata \ + && ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \ + && echo $TZ > /etc/timezone \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=build /app/build/libs/reaction-0.0.1-SNAPSHOT.jar . + +EXPOSE 8083 + +ENTRYPOINT ["java", "-jar", "reaction-0.0.1-SNAPSHOT.jar"]