Skip to content

docs : 가독성 높인 리드미 작성 #7

docs : 가독성 높인 리드미 작성

docs : 가독성 높인 리드미 작성 #7

Workflow file for this run

name: Server CD
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 18
uses: actions/setup-java@v4
with:
java-version: "18"
distribution: "adopt"
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Add application.properties
run: |
mkdir -p ./src/main/resources
touch ./src/main/resources/application.properties
echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.properties
cat ./src/main/resources/application.properties
- name: Build with Gradle
run: ./gradlew clean build
- name: Build docker image
run: |
sudo chmod 666 /var/run/docker.sock
docker buildx build --no-cache --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest -f ./Dockerfile .
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish to Docker Hub
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
- name: Connect to WAS & Execute Application
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
sudo chmod 666 /var/run/docker.sock
sudo chmod +x /usr/local/bin/docker-compose
cd /home/${{ secrets.SERVER_USERNAME }}
sudo docker-compose stop
sudo docker-compose rm -f
sudo docker-compose pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
docker-compose up -d
sudo docker system prune -f
echo "끝"