-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
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 }} |