Skip to content

Merge pull request #69 from Bamsongee/feat/#67-custom-error #59

Merge pull request #69 from Bamsongee/feat/#67-custom-error

Merge pull request #69 from Bamsongee/feat/#67-custom-error #59

Workflow file for this run

name: CD with Gradle
on:
push:
branches: [ "main" ]
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.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.YML }}" > ./application.yml
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.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}/ohmea .
docker push ${{ secrets.DOCKER_REPO }}/ohmea
- name: Deploy to server
uses: appleboy/ssh-action@master
id: deploy
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
envs: GITHUB_SHA
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker stop $(docker ps -a -q)
docker pull ${{ secrets.DOCKER_REPO }}/ohmea
docker-compose up --build -d
sudo docker image prune -f