-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
백엔드 Github Actions CD 파이프라인 구축 (#34)
* deploy flow 작성 * 배포 스크립트 작성
- Loading branch information
1 parent
cb38387
commit 8960a43
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: 배포 | ||
|
||
on: | ||
push: | ||
branches: [main, deploy/33-BE_cd] | ||
workflow_dispatch: | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: execute remote ssh | ||
uses: appleboy/ssh-action@master | ||
env: | ||
REMOTE_SSH_PASSWORD: ${{ secrets.REMOTE_SSH_PASSWORD }} | ||
with: | ||
host: ${{ secrets.REMOTE_SSH_HOST }} | ||
username: ${{ secrets.REMOTE_SSH_USERNAME }} | ||
password: ${{ secrets.REMOTE_SSH_PASSWORD }} | ||
port: ${{ secrets.REMOTE_SSH_PORT }} | ||
envs: BRANCH_NAME, REMOTE_SSH_PASSWORD | ||
script_stop: true | ||
script: | | ||
cd workspaces/1day1baek/back | ||
git reset --hard HEAD | ||
cur_git_branch=$(git branch --show-current) | ||
if [ "$cur_git_branch" != "$BRANCH_NAME" ]; then | ||
git switch main | ||
fi | ||
git pull origin main | ||
server_process=$(ps -ef | grep OneDayOneBaek-0.0.1-SNAPSHOT.jar$ | grep java) | ||
server_pid=(${server_process// / }) | ||
server_pid=${server_pid[1]} | ||
if [ -n "$server_pid" ]; then | ||
echo "existed server pid : $server_pid" | ||
echo $REMOTE_SSH_PASSWORD | sudo -S kill -9 $server_pid | ||
fi | ||
./run_sandbox.sh |