CLAP-104 깃허브액션 dev 환경 ci/cd 스크립트 작성 #1
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 to dev using github actions | |
| # event trigger | |
| # develop 브랜치에 pull_request가 닫혔을 때 실행 | |
| on: | |
| pull_request: | |
| types: [ closed ] | |
| branches: [ "develop" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| DEV-CD: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| ## docker build & push to production | |
| - name: Docker build & push to prod | |
| run: | | |
| docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
| docker build -t ${{ secrets.DOCKER_REPO }} . | |
| docker push ${{ secrets.DOCKER_REPO }} | |
| ## deploy to dev | |
| - name: Deploy to prod | |
| uses: appleboy/ssh-action@master | |
| id: deploy | |
| with: | |
| host: ${{ secrets.DEV_HOST }} | |
| username: ${{ secrets.DEV_HOST_USERNAME }} | |
| key: ${{ secrets.DEV_HOST_KEY }} | |
| port: ${{ secrets.DEV_HOST_PORT }} | |
| script: | | |
| docker rm -f taskflow | |
| docker image rm ${{ secrets.DOCKER_REPO }} -f | |
| docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure |