diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3789815..91a9cf8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,60 +1,43 @@ -name: Java CI with Gradle +name: deploy-actions on: push: branches: [ "prod" ] jobs: - build: - runs-on: ubuntu-22.04 - permissions: - contents: read + ci: + runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/checkout@v3 with: - java-version: '17' - distribution: 'temurin' - - - name: Create Secret Config file - run: | - cd src/main/resources - echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml - ls -l ./application-prod.yml - cat ./application-prod.yml - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 - - - name: Build with Gradle Wrapper - run: ./gradlew build -x test + token: ${{ secrets.GIT_TOKEN }} + submodules: true - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2.9.1 - - - name: Login to DockerHub - uses: docker/login-action@v2.2.0 + - name: Login to Docker Hub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push uses: docker/build-push-action@v4 with: + context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_PROD_REPONAME }}:0.0.1 + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:0.0.1 - deploy: - needs: [build] - runs-on: ubuntu-22.04 + cd: + needs: [ci] + runs-on: ubuntu-20.04 steps: - - name: Docker Image Pull and Container Run + - name: Docker Image Pull And Container Run uses: appleboy/ssh-action@v1.0.0 with: key: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b96745e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "startup-valley-properties"] + path = startup-valley-properties + url = https://github.com/JeongHeumChoi/startup-valley-properties.git + branch = main \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5082b5b..59a7aaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,5 +6,4 @@ RUN ./gradlew clean build -x test FROM openjdk:17-jdk-alpine COPY --from=builder /usr/src/build/libs/startup_valley-0.0.1-SNAPSHOT.jar /usr/app/app.jar -COPY src/main/resources/application-prod.yml /usr/app/config/application-prod.yml -ENTRYPOINT ["java", "-jar", "/usr/app/app.jar", "--spring.config.location=file:/usr/app/config/application-prod.yml"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "/usr/app/app.jar", "--spring.profiles.active=prod"] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0745f33..af6a2a9 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,14 @@ dependencies { testImplementation 'org.springframework.security:spring-security-test' } +task copyGitSubmodule(type: Copy) { + copy { + from './startup-valley-properties' + include '*.yml' + into './src/main/resources' + } +} + tasks.named('test') { useJUnitPlatform() }