From 688a67610518c5feebe00e7e07aa43f5a6eceda2 Mon Sep 17 00:00:00 2001 From: SoohoLee Date: Tue, 13 Jun 2023 18:29:53 +0900 Subject: [PATCH] Create work2.yml --- .github/workflows/work2.yml | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/work2.yml diff --git a/.github/workflows/work2.yml b/.github/workflows/work2.yml new file mode 100644 index 00000000..0d14fc4a --- /dev/null +++ b/.github/workflows/work2.yml @@ -0,0 +1,104 @@ +name: 'work-1' +on: + push: + paths: + - '.github/workflows/**' + - 'src/**' + - 'build.gradle' + - 'Dockerfile' + - 'readme.md' + branches: + - 'main' +jobs: + build: + name: 빌드 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - 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: jdk 17 설치 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'gradle' + - name: gradlew 실행 권한 부여 + run: chmod +x gradlew + - name: gradle 테스트 + run: ./gradlew test --no-daemon + - name: gradle 빌드 + run: ./gradlew build -x test --no-daemon + - name: build 폴더를 캐시에 저장 + uses: actions/upload-artifact@v3 + with: + name: build-artifact + path: build + retention-days: 1 + tag: + name: 태그 생성 + needs: build + runs-on: ubuntu-latest + outputs: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + steps: + - uses: actions/checkout@v3 + - uses: mathieudutour/github-tag-action@v6.1 + id: tag_version + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + docker: + name: 도커 이미지 빌드와 푸시 + runs-on: ubuntu-latest + needs: tag + steps: + - uses: actions/checkout@v3 + - name: build 가져오기 + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: build + - name: Docker Buildx 설치 + uses: docker/setup-buildx-action@v2 + - name: ghcr.io 로그인 + 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: 빌드 앤 푸시 + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ghcr.io/${{ env.OWNER_LC }}/tredpick-1:${{ needs.tag.outputs.tag_name }}, + ghcr.io/${{ env.OWNER_LC }}/tredpick-1:latest + cache-from: type=gha + cache-to: type=gha,mode=max + deploy: + name: 쿠버네티스 배포 + needs: [tag, docker] + runs-on: ubuntu-latest + steps: + - uses: azure/k8s-set-context@v2 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBE_CONFIG }} + - run: | + kubectl set image deployment.apps/tredpick-1 tredpick-1=ghcr.io/angelsooho/tredpick-1:${{ needs.tag.outputs.tag_name }}