프로젝트 및 스터디 스크랩 쿼리 수정 #149
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "deploy" ] | |
pull_request: | |
branches: [ "deploy" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '11.0.2' | |
- name: 💾 Cache Gradle & Spring | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: make application-db.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application-db.properties | |
echo "${{ secrets.PROPERTIES_DB }}" > ./application-db.properties | |
shell: bash | |
- name: make application-oauth.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application-oauth.properties | |
echo "${{ secrets.PROPERTIES_OAUTH }}" > ./application-oauth.properties | |
shell: bash | |
# - name: make application-real.properties | |
# run: | | |
# cd ./src/main/resources | |
# touch ./application-real.properties | |
# echo "${{ secrets.PROPERTIES_REAL }}" > ./application-real.properties | |
# shell: bash | |
- name: make chagok-project-firebase-secure.json | |
id: create-json | |
uses: jsdaniell/[email protected] | |
with: | |
name: "chagok-project-firebase-secure.json" | |
json: ${{ secrets.FIREBASE_KEY }} | |
dir: './src/main/resources' | |
- name: 🔧 Build Spring server | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
ls -al | |
- name: Docker build | |
run: | | |
cd /home/runner/work/Chagok-backend/Chagok-backend | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t app . | |
# 이름은 app으로 f는 현재 경로 -f /home/runner/work/Chagok-backend/Dockerfile | |
docker tag app ${{ secrets.DOCKER_USERNAME }}/chagok:latest | |
# 이름 변경 | |
docker push ${{ secrets.DOCKER_USERNAME }}/chagok:latest | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST}} | |
port: 2023 | |
username: root | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/chagok:latest | |
docker tag ${{ secrets.DOCKER_USERNAME }}/chagok:latest chagok:latest | |
docker stop $(docker ps -a -q) | |
docker run -d --rm -p 8080:8080 --net redis-network --memory 1024m chagok:latest | |
docker run -d --rm -p 6379:6379 --net redis-network --memory 256m redis:latest | |
docker rm $(docker ps --filter 'status=exited' -a -q) | |
# 실행 중이지 않으 모든 컨테인 삭제 | |
docker image prune -a -f | |
# 사용하지않은 모든 이미지 삭제 |