Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions .github/workflows/dev-cd.yml
Original file line number Diff line number Diff line change
@@ -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
## 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
32 changes: 30 additions & 2 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
@@ -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가 열렸을 때 실행
Expand Down Expand Up @@ -47,4 +47,32 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build/libs/*.jar
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
Loading