Skip to content

Merge pull request #33 from 9oormthon-univ/feature/GOORM-3-product #90

Merge pull request #33 from 9oormthon-univ/feature/GOORM-3-product

Merge pull request #33 from 9oormthon-univ/feature/GOORM-3-product #90

Workflow file for this run

name: CD with Gradle
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
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: "adopt"
- name: Make application.properties
run: |
cd ./src/main/resources
touch ./application.properties
echo "${{ secrets.PROPERTIES }}" > ./application.properties
shell: bash
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: Docker build & push to docker repo
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}/danpoong .
docker push ${{ secrets.DOCKER_REPO }}/danpoong
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_PEM_KEY }}
envs: GITHUB_SHA
script: |
echo "DB_HOST=${{ secrets.DB_HOST }}" > .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env
echo "REST_API_KEY=${{ secrets.REST_API_KEY }}" >> .env
sudo docker rm -f $(sudo docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}/danpoong
sudo docker-compose up -d
sudo docker image prune -f