[fix] #4 pullPolicy 강제 추가 #3
This file contains hidden or 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
| name: Deploy Config Server | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'config-server/**' # config-server 폴더가 바뀔 때만 실행 | |
| - '.github/workflows/deploy-config-server.yaml' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. 소스 코드 체크아웃 | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # 2. Docker Hub 로그인 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # 3. 이미지 빌드 및 푸시 | |
| # secrets.DOCKER_USERNAME을 네임스페이스로 사용하여 푸시 | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: ./config-server | |
| file: ./config-server/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKER_USERNAME }}/config-server:latest | |
| ${{ secrets.DOCKER_USERNAME }}/config-server:${{ github.sha }} | |
| # 4. Helm 차트 파일을 서버로 전송 (SCP) | |
| - name: Copy Chart files to Server | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.K8S_HOST }} | |
| username: ${{ secrets.K8S_USERNAME }} | |
| key: ${{ secrets.K8S_PRIVATE_KEY }} | |
| port: ${{ secrets.K8S_PORT }} | |
| source: "config-server/Chart" | |
| target: "~/deploy-temp" # 서버의 홈 디렉토리 밑 deploy-temp로 복사 | |
| strip_components: 0 # 폴더 구조 유지 | |
| # 5. SSH로 접속해서 Helm 배포 실행 | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.K8S_HOST }} | |
| username: ${{ secrets.K8S_USERNAME }} | |
| key: ${{ secrets.K8S_PRIVATE_KEY }} | |
| port: ${{ secrets.K8S_PORT }} | |
| script: | | |
| echo "=== Deploying Config Server ===" | |
| # 1. 이미지 태그 설정 (git sha 사용) | |
| IMAGE_TAG=${{ github.sha }} | |
| # 2. Helm Upgrade 실행 | |
| # --set image.repository: 시크릿에 저장된 이름으로 이미지 경로 설정 | |
| # --set image.pullPolicy=Always: 무조건 최신 이미지를 다운로드 받도록 설정 | |
| helm upgrade --install containerssh-config-server ~/deploy-temp/config-server/Chart \ | |
| --namespace cssh \ | |
| --create-namespace \ | |
| --set image.repository=${{ secrets.DOCKER_USERNAME }}/config-server \ | |
| --set image.tag=$IMAGE_TAG \ | |
| --set image.pullPolicy=Always | |
| echo "=== Deployment Finished ===" |