Merge pull request #34 from letskuku/letskuku #1
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 | |
on: | |
push: | |
branches: | |
- 'letskuku' | |
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' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash | |
- name: Build with Gradle | |
run: ./gradlew bootJar | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name : Build Docker Image & Push to Docker Hub | |
run: | | |
docker build . -t ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | |
docker build ./proxy -t ${{ secrets.DOCKER_HUB_USERNAME }}/nginx | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/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/ | |
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 | |
sudo chmod 666 /var/run/docker.sock | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | |
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/nginx | |
docker-compose -f docker-compose.yml --env-file ./.env up -d | |
docker image prune -f |