Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesecrust committed Mar 19, 2024
2 parents 980ce4c + b3dafbd commit e49cdc3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 29 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Java CI with Gradle

on:
pull_request:
branches: [ "main" ]
types : [closed]

jobs:
build:
if : github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
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: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0

- name: Build with Gradle Wrapper
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 }}/maru:latest
docker push ${{ secrets.DOCKER_USERNAME }}/maru:latest
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }} # EC2 인스턴스 퍼블릭 DNS
username: ec2-user
key: ${{ secrets.AWS_ACCESS_SECRET_KEY }} # pem 키
# 도커 작업
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/maru:latest
docker stop $(docker ps -a -q)
docker run -d --log-driver=syslog -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod ${{ secrets.DOCKER_USERNAME }}/maru:latest
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f
29 changes: 0 additions & 29 deletions .github/workflows/super-linter.yml

This file was deleted.

0 comments on commit e49cdc3

Please sign in to comment.