[Feat] 연관 관계 변경 #34
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
## develop 브랜치에 push가 되면 실행됩니다 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
## gradle build | |
- name: Build with Gradle | |
run: | | |
chmod +x gradlew | |
./gradlew bootJar | |
## 웹 이미지 빌드 및 도커허브에 push | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t joyoonjoo731/ceos-vote . | |
docker push joyoonjoo731/ceos-vote | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
cd /home/ubuntu/ | |
sudo touch .env | |
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null | |
sudo touch docker-compose.yml | |
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null | |
## docker-compose 실행 | |
sudo chmod 666 /var/run/docker.sock | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull joyoonjoo731/ceos-vote | |
docker-compose -f docker-compose.yml --env-file ./.env up -d | |
docker image prune -f |