Merge pull request #152 from 2024-startup/BE/feat/#151 #83
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
# 워크플로우 이름 설정 | |
name: Deploy Spring Boot App | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
deploy: | |
# 실행 환경 설정 | |
runs-on: ubuntu-latest | |
environment: envs | |
steps: | |
# 저장공간 설정 | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# artifact 다운로드 | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ github.event.workflow_run.id }} | |
github-token: ${{ github.token }} | |
name: server-jar | |
path: ./app | |
# docker-compose.yml 파일 이동 | |
- name: Move docker-compose_for_action.yml | |
run: | | |
mv ./docker-compose_for_action.yml ./app/docker-compose_for_action.yml | |
# Docker 이미지를 서버로 전송 | |
- name: file to Server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.REMOTE_SSH_HOST }} | |
username: ${{ secrets.REMOTE_SSH_USERNAME }} | |
key: ${{ secrets.REMOTE_SSH_KEY }} | |
source: ./app/* | |
target: ./ | |
# 서버에서 Docker 이미지 빌드 및 실행 | |
- name: Deploy to Server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.REMOTE_SSH_HOST }} | |
username: ${{ secrets.REMOTE_SSH_USERNAME }} | |
key: ${{ secrets.REMOTE_SSH_KEY }} | |
script: | | |
cd ./app | |
echo "SPRING_DATASOURCE_URL=${{ secrets.SPRING_DATASOURCE_URL }}" >> ./backend.env | |
echo "SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }}" >> ./backend.env | |
echo "SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }}" >> ./backend.env | |
echo "SPRING_DATASOURCE_DRIVER_CLASS_NAME=${{ secrets.SPRING_DATASOURCE_DRIVER_CLASS_NAME }}" >> ./backend.env | |
echo "SPRING_JPA_DATABASE=${{ secrets.SPRING_JPA_DATABASE }}" >> ./backend.env | |
echo "S3_BUCKET_URL=${{ secrets.S3_BUCKET_URL }}" >> ./backend.env | |
echo "S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}" >> ./backend.env | |
echo "S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }}" >> ./backend.env | |
echo "S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }}" >> ./backend.env | |
docker-compose -f docker-compose_for_action.yml up -d |