Skip to content

Commit

Permalink
Update and rename deploy.yml to gradle.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
yeopyeop-82 authored Sep 9, 2024
1 parent 740675c commit 6c4688c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 40 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/deploy.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Java CI with Gradle

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

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-prod.yml
run: |
cd ./src/main/resources
touch ./application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/sejongmate:latest
docker push ${{ secrets.DOCKER_USERNAME }}/sejongmate:latest
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }} # pem 키
# 도커 작업
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/sejongmate:latest
docker stop $(docker ps -a -q)
docker run -d --log-driver=syslog -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/sejongmate:latest
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f

0 comments on commit 6c4688c

Please sign in to comment.