[refactor] fetchCount -> fetchOne으로 수정 #205
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 & CD with Gradle | |
on: | |
push: | |
branches: [ "develop" ] | |
# pull_request: | |
# branches: [ "develop" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: application.yml 설정 | |
run: | | |
cd ./src/main | |
mkdir resources | |
cd ./resources | |
touch ./application.yml | |
echo "$APPLICATION_MAIN" > ./application.yml | |
env: | |
APPLICATION_MAIN: ${{ secrets.APPLICATION_MAIN }} | |
- 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 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
## 웹 이미지 빌드 및 도커허브에 push | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPO }}/blue-green . | |
docker push ${{ secrets.DOCKER_REPO }}/blue-green | |
## deploy.sh 파일 서버로 전달하기(복사 후 붙여넣기) | |
- name: Send deploy.sh | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.HOST }} | |
key: ${{ secrets.KEY }} | |
port: 22 | |
source: "./scripts/" | |
target: "/home/ubuntu/" | |
## docker-compose.yml 파일을 EC2 development server로 전달 | |
- name: Send docker-compose.yml | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.HOST }} | |
key: ${{ secrets.KEY }} | |
port: 22 | |
source: "./docker-compose.yml" | |
target: "/home/ubuntu/" | |
## 도커 허브에서 jar파일 및 pull후에 컴포즈 up | |
- name: Deploy to Dev | |
uses: appleboy/ssh-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.HOST }} | |
key: ${{ secrets.KEY }} | |
script: | | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/blue-green | |
chmod 777 ./scripts/deploy.sh | |
cp ./scripts/deploy.sh ./deploy.sh | |
./deploy.sh | |
docker image prune -f |