Update README.md #31
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: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
package: 'jdk' | |
jdk-version: '17.0.6' | |
- name: checkout | |
uses: actions/checkout@main | |
- name: create env and secure file | |
run: | | |
touch .env | |
echo "${{ secrets.ENV_VARS }}" >> .env | |
cd src/main/resources | |
touch secure.properties | |
echo "${{ secrets.SECURE_VARS }}" >> secure.properties | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
- name: Image build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker-compose -f docker-compose-prod.yml build | |
docker push ariaserver/aria-server | |
- name: Up docker-compose | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} # EC2 인스턴스 퍼블릭 DNS | |
username: ubuntu | |
key: ${{ secrets.SSH_PRIVATE_KEY }} # pem 키 | |
# 도커 작업 | |
script: | | |
sudo docker stop ubuntu_app_1 | |
sudo docker rm ubuntu_app_1 | |
sudo docker rmi ariaserver/aria-server | |
sudo docker pull ariaserver/aria-server | |
sudo docker-compose -f docker-compose-prod.yml up -d |