Workflow file for this run
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
| # github repository actions 페이지에 나타날 이름 | |
| name: CD for front using github actions | |
| on: | |
| release: | |
| types: [ created ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| front-cd: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 저장소 코드를 체크아웃합니다. (PR 올린 코드를 가져오는 행위) | |
| - uses: actions/checkout@v4 | |
| # Node.js 환경 설정 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 # 지정된 Node.js 버전 사용 | |
| cache: npm # setup-node 의 캐시 기능을 사용함 | |
| cache-dependency-path: package-lock.json # 캐시 기능을 사용할 때 캐시의 기준이 될 파일을 지정 | |
| - name: Extract release version | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Build with npm | |
| run: npm run build-only | |
| - name: Create nginxfile.conf | |
| run: touch ./nginxfile.conf | |
| - run: echo "${{ secrets.NGINX_FILE_CONF }}" > ./nginxfile.conf | |
| - name: Create Production nginx.conf | |
| run: touch ./nginx.conf | |
| - run: echo "${{ secrets.PROD_NGINX_CONF }}" > ./nginx.conf | |
| # docker build & push to production | |
| - name: Docker build & push production | |
| run: | | |
| docker login clap.kr-central-2.kcr.dev -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
| docker build -t ${{ secrets.DOCKER_FRONT_REPO }}:${{ steps.version.outputs.VERSION }} . | |
| docker push ${{ secrets.DOCKER_FRONT_REPO }}:${{ steps.version.outputs.VERSION }} | |
| - name: Update Kubernetes Deployment | |
| run: | | |
| envsubst < ./taskflow.yaml > ./taskflow-front.yaml | |
| env: | |
| IMAGE_TAG: ${{ steps.version.outputs.VERSION }} | |
| # deploy | |
| - name: Transport taskflow.yaml to kubectl server | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.KUBE_HOST }} | |
| username: ${{ secrets.KUBE_HOST_USERNAME }} | |
| key: ${{ secrets.KUBE_HOST_KEY }} | |
| port: ${{ secrets.KUBE_HOST_PORT }} | |
| overwrite: true | |
| source: ./taskflow-front.yaml | |
| target: ~/ | |
| - name: Deploy Prod | |
| uses: appleboy/ssh-action@master | |
| id: deployProd | |
| with: | |
| host: ${{ secrets.KUBE_HOST }} | |
| username: ${{ secrets.KUBE_HOST_USERNAME }} | |
| key: ${{ secrets.KUBE_HOST_KEY }} | |
| port: ${{ secrets.KUBE_HOST_PORT }} | |
| script: | | |
| kubectl apply --filename taskflow-front.yaml |