Feat: 대댓글 CRUD 구현 #173
Workflow file for this run
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: Codiary CI/CD | |
on: | |
pull_request: | |
branches: | |
- develop | |
permissions: write-all | |
jobs: | |
build: | |
# ubuntu 버전 지정 | |
runs-on: ubuntu-22.04 | |
steps: | |
# 소스 코드 체크아웃 | |
- uses: actions/checkout@v4 | |
# Build를 위한 JDK 설치 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
# Gradle 캐싱 | |
- name: Cache | |
uses: actions/cache@v4.0.2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Gradle 권한 부여 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# application.yml 생성 | |
- name: Make application-secret.yml | |
run: | | |
cd ./src/main | |
[ ! -d "resources" ] && mkdir resources | |
cd ./resources | |
touch ./application.yml | |
echo "${{ secrets.APPLICATION_SECRET_YML}}" > ./application.yml | |
shell: bash | |
# Gradle clean bootJar | |
- name: Build Gradle | |
run: ./gradlew clean bootJar | |
# resources 디렉토리 내용 출력 (디버깅용) | |
- name: List resources directory | |
run: | | |
ls -l ./src/main/resources | |
if [ -f ./src/main/resources/adjective.txt ]; then echo "adjective.txt exists"; else echo "adjective.txt does not exist"; fi | |
shell: bash | |
# Docker Image Push | |
- name: Docker Image push | |
run: | | |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME}}/${{ secrets.DOCKERHUB_REPOSITORY}} ./ | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY}} | |
# Docker Compose | |
- name: Docker Compose | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_SERVER_IP }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
cd .ssh/Backend-Codiary/ | |
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} | |
sudo docker-compose stop ${{ secrets.DOCKER_SERVICE_NAME }} | |
sudo docker-compose rm -f ${{ secrets.DOCKER_SERVICE_NAME }} | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY}} | |
sudo docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY}} ${{ secrets.DOCKER_IMAGE_NAME }} | |
sudo docker compose up -d |