API: ํ๋ก์ฐ ๊ธฐ๋ฅ swagger ์ค์ #30
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@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
# Gradle ์บ์ฑ | |
- name: Cache | |
uses: actions/[email protected] | |
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 | |
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 |