-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE-81] CD 개발 서버 추가 배포 및 포트 포워딩 변수 추가 #217
[BE-81] CD 개발 서버 추가 배포 및 포트 포워딩 변수 추가 #217
- Loading branch information
Showing
7 changed files
with
217 additions
and
38 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,104 @@ | ||
name: 개발서버 배포 플로우 | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
SSH_HOST: | ||
required: true | ||
SSH_USERNAME: | ||
required: true | ||
SSH_KEY: | ||
required: true | ||
SSH_PORT: | ||
required: true | ||
SLACK_WEBHOOK_URL: | ||
required: true | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
image-tag: | ||
required: true | ||
type: string | ||
spring-profile-active: | ||
required: true | ||
type: string | ||
image-name: | ||
required: true | ||
type: string | ||
service-name: | ||
required: true | ||
type: string | ||
|
||
env: | ||
IMAGE_TAG: 'latest' | ||
ACTIVE_PROFILE: ${{ inputs.spring-profile-active || 'local' }} | ||
ENVIRONMENT: ${{ inputs.environment || 'local' }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: [ ubuntu-latest ] | ||
name: 서비스 배포하기 | ||
environment: ${{ inputs.environment }} | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- name: GitHub 에서 레포 받아오기 | ||
uses: actions/checkout@v3 | ||
|
||
- name: 개발서버 배포 스크립트 실행 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.DEV_SSH_HOST }} | ||
username: ${{ secrets.DEV_SSH_USERNAME }} | ||
key: ${{ secrets.DEV_SSH_KEY }} | ||
port: ${{ secrets.DEV_SSH_PORT }} | ||
script: | | ||
cd ./econo-recruit/server | ||
# Remove origin was container | ||
docker rm -f backend | ||
# Pull and Deploy new built docker image with new tag | ||
docker pull blackbean99/econo-recruit:latest | ||
docker-compose up -d --remove-orphans | ||
docker image prune -a -f | ||
- name: 배포 완료 슬랙 알림 보내기 | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
status: custom | ||
fields: author, workflowRun, pullRequest | ||
custom_payload: | | ||
{ | ||
attachments: [{ | ||
color: '#59f764', | ||
title: '서버 배포 알림', | ||
text: `Econo-Recruit 서버 배포 성공!`, | ||
fields: [ | ||
{ | ||
title: '배포 환경', | ||
value: `${process.env.ENVIRONMENT}`, | ||
short: true, | ||
}, | ||
{ | ||
title: '배포자', | ||
value: `${process.env.AS_AUTHOR}`, | ||
short: true, | ||
}, | ||
{ | ||
title: '워크플로 링크', | ||
value: `${process.env.AS_WORKFLOW_RUN}`, | ||
short: true, | ||
}, | ||
{ | ||
title: 'PR 링크', | ||
value: `${process.env.AS_PULL_REQUEST}`, | ||
short: true, | ||
} | ||
] | ||
}] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
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,100 @@ | ||
name: 배포 워크플로우 | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
- backend | ||
env: | ||
SPRING_PROFILES_ACTIVE: local | ||
ENVIRONMENT: production | ||
IMAGE_NAME: blackbean99/econo-recruit | ||
SERVICE_NAME: Econovation_Recruit_Server | ||
|
||
concurrency: | ||
group: production | ||
|
||
|
||
jobs: | ||
prepare-environments: | ||
name: 환경 변수 설정 | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image-name: ${{ steps.setup-env.outputs.image-name }} | ||
image-tag: ${{ steps.setup-env.outputs.image-tag }} | ||
spring-profile-active: ${{ steps.setup-env.outputs.spring-profile-active }} | ||
environment: ${{ steps.setup-env.outputs.environment }} | ||
service-name: ${{ steps.setup-env.outputs.service-name }} | ||
|
||
steps: | ||
- name: Github에서 레포 받아오기 | ||
uses: actions/checkout@v3 | ||
|
||
- name: 환경 변수 설정 | ||
id: setup-env | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
run: | | ||
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT | ||
echo "image-tag=latest" >> $GITHUB_OUTPUT | ||
# $(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
echo "spring-profile-active=$SPRING_PROFILES_ACTIVE" >> $GITHUB_OUTPUT | ||
echo "environment=$ENVIRONMENT" >> $GITHUB_OUTPUT | ||
echo "service-name=$SERVICE_NAME" >> $GITHUB_OUTPUT | ||
echo "::set-env name=DOCKERHUB_USERNAME::${{ secrets.DOCKERHUB_USERNAME }}" | ||
echo "::set-env name=DOCKERHUB_PASSWORD::${{ secrets.DOCKERHUB_PASSWORD }}" | ||
echo "::set-env name=MYSQL_HOST::${{ secrets.MYSQL_HOST }}" | ||
echo "::set-env name=MYSQL_PORT::${{ secrets.MYSQL_PORT }}" | ||
echo "::set-env name=MYSQL_DATABASE::${{ secrets.MYSQL_DATABASE }}" | ||
echo "::set-env name=MYSQL_USERNAME::${{ secrets.MYSQL_USERNAME }}" | ||
echo "::set-env name=MYSQL_PASSWORD::${{ secrets.MYSQL_PASSWORD }}" | ||
echo "::set-env name=JWT_SECRET::${{ secrets.JWT_SECRET }}" | ||
echo "::set-env name=SONAR_TOKEN::${{ secrets.SONAR_TOKEN }}" | ||
call-ci-check-workflow: | ||
if: github.event_name == 'push' | ||
name: CI_CHECK(spotless, sonar) 정적분석 | ||
uses: ./.github/workflows/CI_Check.yml | ||
permissions: | ||
id-token: write | ||
contents: read | ||
secrets: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
call-build-workflow: | ||
if: github.event_name == 'push' | ||
needs: [ prepare-environments ] | ||
name: 서비스 빌드 | ||
uses: ./.github/workflows/build.yml | ||
permissions: | ||
id-token: write | ||
contents: read | ||
with: | ||
image-tag: 'latest' | ||
# ${{ needs.prepare-environments.outputs.image-tag }} | ||
spring-profile-active: ${{ needs.prepare-environments.outputs.spring-profile-active }} | ||
image-name: ${{ needs.prepare-environments.outputs.image-name }} | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
call-deploy-workflow: | ||
if: github.event_name == 'push' | ||
needs: [ prepare-environments, call-build-workflow ] | ||
name: 서비스 배포 | ||
uses: ./.github/workflows/dev-deploy.yml | ||
permissions: | ||
id-token: write | ||
contents: read | ||
secrets: | ||
SSH_HOST: ${{ secrets.DEV_SSH_HOST }} | ||
SSH_USERNAME: ${{ secrets.DEV_SSH_USERNAME }} | ||
SSH_KEY: ${{ secrets.DEV_SSH_KEY }} | ||
SSH_PORT: ${{ secrets.DEV_SSH_PORT }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
with: | ||
image-tag: ${{ needs.prepare-environments.outputs.image-tag }} | ||
spring-profile-active: ${{ needs.prepare-environments.outputs.spring-profile-active }} | ||
environment: ${{ needs.prepare-environments.outputs.environment }} | ||
image-name: ${{ needs.prepare-environments.outputs.image-name }} | ||
service-name: ${{ needs.prepare-environments.outputs.service-name }} | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ name: 배포 워크플로우 | |
on: | ||
push: | ||
branches: | ||
- release | ||
- backend | ||
env: | ||
SPRING_PROFILES_ACTIVE: local | ||
|
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
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