diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..54e55b1 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +*.* @gurdl0525 \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..f16a11a --- /dev/null +++ b/.github/workflows/cd.yml @@ -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) \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d9ebab0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file