Skip to content

Merge pull request #115 from catchroom/develop #101

Merge pull request #115 from catchroom/develop

Merge pull request #115 from catchroom/develop #101

Workflow file for this run

# github repository actions νŽ˜μ΄μ§€μ— λ‚˜νƒ€λ‚  이름
name: CI/CD using github actions & docker
# event trigger
# main λΈŒλžœμΉ˜μ— pushκ°€ λ˜μ—ˆμ„ λ•Œ μ‹€ν–‰
on:
push:
branches: [ "main" ]
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: Create application.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
cat ./src/main/resources/application.yml
echo "${{ secrets.DOCKER-COMPOSE }}" > docker-compose.yml
cat docker-compose.yml
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PWD }}
docker buildx build --push --platform linux/amd64 -t ${{ secrets.DOCKER_IMAGE_NAME }} .
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_NAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker stop prod1
sudo docker stop prod2
sudo docker pull ${{ secrets.DOCKER_IMAGE_NAME }}
docker-compose up -d
sudo docker image prune -af
# sleep 10
# sudo docker stop chat-server-2
# sudo docker run -d --rm --name chat-server-2 -p 8082:8080 ${{ secrets.DOCKER_IMAGE_NAME }}