Merge remote-tracking branch 'origin/develop' into develop #121
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: Java CI with Gradle | |
on: [ "push" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Make build properties | |
run: | | |
mkdir -p ./grow-api/src/main/resources | |
touch ./grow-api/src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION }}" > ./grow-api/src/main/resources/application.yml | |
touch ./grow-api/src/main/resources/grow-firebase.json | |
echo "${{ secrets.GROW_FIREBASE_JSON }}" | base64 -d -i - > ./grow-api/src/main/resources/grow-firebase.json | |
- name: Build with Gradle | |
run: | | |
chmod +x gradlew | |
./gradlew :grow-api:build -x test --parallel | |
- name: Docker build | |
if: github.ref == 'refs/heads/develop' | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/grow:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/grow:latest | |
publish: | |
if: ${{ always() && contains(join(needs.*.result, ','), 'success') && github.ref == 'refs/heads/develop' }} | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Deploy with SSH | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS | |
username: ubuntu | |
key: ${{ secrets.PRIVATE_KEY }} # pem 키 | |
# 도커 작업 | |
script: | | |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker rm -f $(docker ps -a -q --filter ancestor=${{ secrets.DOCKER_USERNAME }}/grow) | |
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/grow:latest | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/grow:latest | |
sudo docker run -d --name grow-app --log-driver=syslog -p 80:8080 \ | |
${{ secrets.DOCKER_USERNAME }}/grow:latest | |
sudo docker network connect redis-network $(docker ps -a -q --filter ancestor=${{ secrets.DOCKER_USERNAME }}/grow) |