Skip to content

Merge pull request #44 from Onion-City/feat/oauth2 #22

Merge pull request #44 from Onion-City/feat/oauth2

Merge pull request #44 from Onion-City/feat/oauth2 #22

Workflow file for this run

# 작업명
name: CD Pipeline
on:
push:
branches:
- 'develop'
- 'main'
jobs:
CD:
runs-on: ubuntu-latest
env:
RESOURCE_PATH: ./src/main/resources/application.yml
steps:
## Project JDK 17 Setting
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set yml file
uses: microsoft/variable-substitution@v1
with:
files: ${{ env.RESOURCE_PATH }}
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USERNAME }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
spring.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.ddl-auto: update
spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.MariaDB103Dialect
# Login to ghcr
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: pinetree2
password: ${{ secrets.GHCR_TOKEN }}
# Docker 빌드 생성 및 푸시
- name: dev Docker build & push
if: contains(github.ref, 'main') || contains(github.ref, 'develop')
run: |
docker build -f Dockerfile -t ghcr.io/onion-city/whatssue_be_v2/whatssue:latest .
docker push ghcr.io/onion-city/whatssue_be_v2/whatssue:latest
# 개발서버 SSH접속 및 배포
- name: Deploy
uses: appleboy/ssh-action@master
id: deploy
if: contains(github.ref, 'main') || contains(github.ref, 'develop')
with:
host: ${{ secrets.DEV_SERVER_DNS }}
username: ${{ secrets.DEV_SERVER_USER }}
password: ${{ secrets.DEV_SERVER_PASSWORD }}
port: ${{ secrets.DEV_SERVER_SSH_PORT }}
script: |
echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u pinetree2 --password-stdin
if [ "$(docker ps -aq -f name=whatssue-be)" ]; then
sudo docker stop whatssue-be
sudo docker rm whatssue-be
fi
if [ "$(docker images -q ghcr.io/onion-city/whatssue_be_v2/whatssue)" ]; then
sudo docker rmi ghcr.io/onion-city/whatssue_be_v2/whatssue
fi
sudo docker pull ghcr.io/onion-city/whatssue_be_v2/whatssue:latest
sudo docker stop whatssue-be
sudo docker rm whatssue-be
sudo docker run -d -p 8080:8080 --name whatssue-be ghcr.io/onion-city/whatssue_be_v2/whatssue:latest
sudo docker image prune -a -f