From ad1565369ae790435cefcdbeda2faaf4a695bfb4 Mon Sep 17 00:00:00 2001 From: sik2 Date: Tue, 14 Jan 2025 05:09:51 +0900 Subject: [PATCH] work --- .github/workflows/deploy.yml | 67 +++++++++++++++++++ ...K8sDeploySbDemo2501v1ApplicationTests.java | 2 + 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c6e8af1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,67 @@ +name: 'deploy' +on: + push: + paths: + - '.github/workflows/**' + - 'src/**' + - 'build.gradle' + - 'Dockerfile' + - 'readme.md' + - 'infraScript/**' + branches: + - 'main' +jobs: + makeTagAndRelease: + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.create_tag.outputs.new_tag }} + steps: + - uses: actions/checkout@v4 + - name: Create Tag + id: create_tag + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.create_tag.outputs.new_tag }} + release_name: Release ${{ steps.create_tag.outputs.new_tag }} + body: ${{ steps.create_tag.outputs.changelog }} + draft: false + prerelease: false + buildImageAndPush: + name: 도커 이미지 빌드와 푸시 + needs: makeTagAndRelease + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Docker Buildx 설치 + uses: docker/setup-buildx-action@v2 + - name: 레지스트리 로그인 + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: set lower case owner name + run: | + echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} + env: + OWNER: "${{ github.repository_owner }}" + - name: application-secret.yml 생성 + env: + ACTIONS_STEP_DEBUG: true + APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET_YML }} + run: echo "$APPLICATION_SECRET" > src/main/resources/application-secret.yml + - name: 빌드 앤 푸시 + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ghcr.io/${{ env.OWNER_LC }}/k8s-deploy-sb-2501:${{ needs.makeTagAndRelease.outputs.tag_name }}, + ghcr.io/${{ env.OWNER_LC }}/k8s-deploy-sb-2501:latest \ No newline at end of file diff --git a/src/test/java/com/ll/k8s/K8sDeploySbDemo2501v1ApplicationTests.java b/src/test/java/com/ll/k8s/K8sDeploySbDemo2501v1ApplicationTests.java index 2106142..f1c7f34 100644 --- a/src/test/java/com/ll/k8s/K8sDeploySbDemo2501v1ApplicationTests.java +++ b/src/test/java/com/ll/k8s/K8sDeploySbDemo2501v1ApplicationTests.java @@ -2,8 +2,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; @SpringBootTest +@ActiveProfiles("Test") class K8sDeploySbDemo2501v1ApplicationTests { @Test