diff --git a/.github/workflows/dev-cd.yml b/.github/workflows/dev-cd.yml index 3514bec4..1522f947 100644 --- a/.github/workflows/dev-cd.yml +++ b/.github/workflows/dev-cd.yml @@ -1,44 +1,44 @@ -# 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 - github-token: ${{ secrets.GH_TOKEN }} - - ## 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 \ No newline at end of file +## 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 +# github-token: ${{ secrets.GH_TOKEN }} +# +# ## 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 diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml index 51faf1fb..5034f91b 100644 --- a/.github/workflows/dev-ci.yml +++ b/.github/workflows/dev-ci.yml @@ -1,5 +1,5 @@ # github repository actions 페이지에 나타날 이름 -name: CI for dev using github actions +name: CI/CD to dev using github actions # event trigger # develop 브랜치에 pull_request가 열렸을 때 실행 @@ -47,4 +47,32 @@ jobs: uses: actions/upload-artifact@v4 with: name: build-artifacts - path: build/libs/*.jar \ No newline at end of file + path: build/libs/*.jar + + DEV-CD: + if: github.event.action == 'closed' && github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + github-token: ${{ secrets.GH_TOKEN }} + + - 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 }} + + - name: Deploy to dev + uses: appleboy/ssh-action@master + 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 || true + docker image rm ${{ secrets.DOCKER_REPO }} -f || true + docker run --name taskflow --network host -d -p 8080:8080 ${{ secrets.DOCKER_REPO }} --restart on-failure \ No newline at end of file