Merge pull request #45 from yeni-choi/yeni-choi #9
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: Deploy Development Server | |
on: | |
push: | |
branches: [ "yeni-choi" ] | |
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: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
## 웹 이미지 빌드 및 도커허브에 push | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t yeniwithchoi/ceos-karrot . | |
docker push yeniwithchoi/ceos-karrot | |
docker build -f dockerfile-nginx -t yeniwithchoi/ceos-nginx . | |
docker push yeniwithchoi/ceos-nginx | |
- 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/ | |
## .env 파일을 생성합니다. | |
sudo touch .env | |
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null | |
## docker-compose를 실행합니다. | |
sudo chmod 666 /var/run/docker.sock | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull yeniwithchoi/ceos-karrot | |
sudo docker pull yeniwithchoi/ceos-nginx | |
docker-compose -f docker-compose.yml --env-file ./.env up -d | |
docker image prune -f |