Skip to content

Commit

Permalink
⭐️ :: CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
gurdl0525 committed Nov 9, 2023
1 parent bc95b7a commit 313b816
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.* @gurdl0525
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CD

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

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: Set up .jar
run: ./gradlew bootJar

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ${{ secrets.DOCKER_REPOSITORY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Deploy For EC2 # EC2 ssh 접속
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
port: ${{ secrets.EC2_SSH_PORT }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
docker stop${{ secrets.SERVER_NAME }}
docker rm ${{ secrets.SERVER_NAME }}
docker pull ${{ secrets.DOCKER_REPOSITORY }}
docker run -dp ${{ secrets.HOST_PORT }}:${{ secrets.DOCKER_CONTAINER_PORT }} --name ${{ secrets.SERVER_NAME }} --env-file ${{ secrets.ENV_PATH }} ${{ secrets.DOCKER_REPOSITORY }}
docker rmi $(docker images -f "dangling=true" -q)
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main
- develop

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: Run ktlint
run: ./gradlew ktlintCheck

- name: Set up application.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.MAIN_APPLICATION }}" | base64 --decode > src/main/resources/application.yml
mkdir -p src/test/resources
echo "${{ secrets.TEST_APPLICATION }}" | base64 --decode > src/test/resources/application.yml
- name: run test
run: ./gradlew test

- name: run build
run: ./gradlew clean build -x test

0 comments on commit 313b816

Please sign in to comment.