Skip to content

배포 - deploy-gitops #36

배포 - deploy-gitops

배포 - deploy-gitops #36

Workflow file for this run

name: 백엔드 서버 배포 파이프라인
run-name: 배포 - ${{ github.ref_name }}
on:
workflow_dispatch:
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- name: 체크아웃으로 소스코드 가져오기
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: jdk 17 설치
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: 그레이들 권한
run: chmod 777 gradlew
- name: 그레이들 빌드
run: ./gradlew build -x test -x koverVerify
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 도커 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 도커 이미지 빌드 및 도커허브에 이미지 올리기
uses: docker/[email protected]
with:
context: ./mains/monolith-main
platforms: linux/arm64
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/blog-backend:${{ github.sha }}
gitops-update:
needs: docker-build
runs-on: ubuntu-latest
steps:
- name: GitOps 레포지토리 클론
uses: actions/checkout@v4
with:
repository: jinia91/blog-gitops
token: ${{ secrets.GIT_OPS_TOKEN }}
path: gitops-repo
- name: 배포 태그 업데이트
working-directory: ./gitops-repo
run: |
yq -i '.spec.template.spec.containers[0].image = "jinia91/blog-backend:${{ github.sha }}"' deploy/jiniaslog/monolith/jiniaslog-main.yml
- name: GitOps 레포지토리 커밋 및 푸시
working-directory: ./gitops-repo
run: |
git config --global user.name "GitOps Bot"
git config --global user.email "[email protected]"
git add .
git commit -m "업데이트 blog-backend:${{ github.sha }}"
git push