Skip to content

Merge pull request #80 from HanaFun/dev #27

Merge pull request #80 from HanaFun/dev

Merge pull request #80 from HanaFun/dev #27

Workflow file for this run

name: CI/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: "temurin"
- name: make application yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > src/main/resources/application.yml
find src
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_YUB }} -p ${{ secrets.DOCKER_PASSWORD_YUB }}
docker build -f Dockerfile -t "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest" .
docker push "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest"
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_SSH_KEY }}
script: |
sudo docker ps
sudo docker pull "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest"
sudo docker stop hanafun
sudo docker rm hanafun
sudo docker run -d -p 8080:8080 --name hanafun "${{ secrets.DOCKER_USERNAME_YUB }}/hanafun:latest"
sudo docker image prune -f