Skip to content

[fix] 응답이 아예 안 보이는 문제 해결 시도 #17

[fix] 응답이 아예 안 보이는 문제 해결 시도

[fix] 응답이 아예 안 보이는 문제 해결 시도 #17

Workflow file for this run

# github repository actions 페이지에 나타날 이름
name: CI/CD using github actions
# event trigger
# main 브랜치에 push 됐을때 실행
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Set up jdk'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin' # https://github.com/actions/setup-java
# gradle caching - 빌드 시간 향상
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## gradle build with test
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew build
## docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPO }} .
docker push ${{ secrets.DOCKER_REPO }}
## deploy to production
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy
if: contains(github.ref, 'main')
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.HOST_USERNAME }}
password: ${{ secrets.HOST_PASSWORD }}
port: ${{ secrets.HOST_PORT }}
script: |
docker rm -f gpt-be
docker image rm ${{ secrets.DOCKER_REPO }} -f
docker pull ${{ secrets.DOCKER_REPO }}
docker run -d --name gpt-be --network host --env DB_CONNECTION=${{secrets.DB_CONNECTION}} --env DB_NAME=${{secrets.DB_NAME}} --env GPT_DB_USERNAME=${{secrets.GPT_DB_USERNAME}} --env GPT_DB_PASSWORD=${{secrets.GPT_DB_PASSWORD}} --env FLASK_DOMAIN=${{secrets.FLASK_DOMAIN}} --env SALT=${{secrets.SALT}} ${{secrets.DOCKER_REPO }} --restart on-failure