feat : s3 설정 3트 #140
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: TIFY CI/CD | |
on: | |
push: | |
branches: [ "dev", "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: TIFY CI/CD | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup jdk-17 | |
uses: actions/setup-java@main | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Docker build | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest | |
# AWS EC2 Server Connect & Docker 명령어 실행 | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.AWS_HOST }} | |
username: ubuntu | |
key: ${{ secrets.AWS_KEY }} | |
timeout: 60s | |
# 도커 작업 | |
script: | | |
cd ~/srv | |
sh ~/srv/ubuntu/config/scripts/docker-init.sh | |
sudo rm concal.log | |
sudo docker rm - f $(docker ps -qa) | |
sudo docker-compose pull | |
sudo docker stop $(docker ps -a -q) | |
sudo docker-compose -f docker-compose.test.yml up -d | |
sudo docker logs -f backend &> concal.log & | |
sudo docker image prune -f |