From 07af7f9bd4e35336273c036c1cd440fe88cdcb66 Mon Sep 17 00:00:00 2001 From: kyoohyun Date: Wed, 1 Feb 2023 16:04:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?GM-176=20GithubAction=20CI=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=8C=8C=EC=9D=BC,=20Dockerfile=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PR_TEMPLATE.md | 30 +++++++++++++++++ .github/workflows/ci.yml | 73 ++++++++++++++++++++++++++++++++++++++++ Dockerfile | 5 +++ 3 files changed, 108 insertions(+) create mode 100644 .github/PR_TEMPLATE.md create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile diff --git a/.github/PR_TEMPLATE.md b/.github/PR_TEMPLATE.md new file mode 100644 index 0000000..846f690 --- /dev/null +++ b/.github/PR_TEMPLATE.md @@ -0,0 +1,30 @@ +# Issue# - Issue +## Description +> + +## PR Type +- [ ] Hotfix +- [ ] Feature +- [ ] Code style update +- [ ] Refactor (code, package, etc.) +- [ ] Build (gradle, spring, etc) +- [ ] Documentation content changes (api docs, etc.) +- [ ] Infra (cloud, security, etc.) +- [ ] Other... Please describe : + +## Related Issues +- + +## Issues + +### Test + +*** + +## Related Files +- `file` + +## Think About.. + +## Conclusion +> diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d63bfc9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ + + +name: Java CI with Gradle + +on: + + pull_request: + + +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: Create secret.yml + env: + SECRET_CODE: ${{ secrets.SECRET }} + SECRET_DIR: src/main/resources + SECRET_FILE_NAME: secret.yml + run: echo $SECRET_CODE | base64 --decode > $SECRET_DIR/$SECRET_FILE_NAME + + - name: Create application-oauth.yml + env: + SECRET_CODE: ${{ secrets.OAUTH }} + SECRET_DIR: src/main/resources + SECRET_FILE_NAME: application-oauth.yml + run: echo $SECRET_CODE | base64 --decode > $SECRET_DIR/$SECRET_FILE_NAME + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name : Set Eureka Server + run: | + docker pull ${{ secrets.EUREKA }} + docker run -d -p 8761:8761 ${{ secrets.EUREKA }} + + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build + + - name: Set up docker buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to ghcr + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: show directory + run: ls + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . # dockerfile이 있는 위치랑 맞춰주자 + file: ./Dockerfile # 빌드할 Dockerfile이 있는 디렉토리 + push: true + tags: ${{ env.DOCKER_IMAGE }}:local \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc50e69 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM openjdk:17-alpine +VOLUME /tmp +COPY build/libs/auth-0.0.1-SNAPSHOT.jar api.jar +EXPOSE 8080 +ENTRYPOINT ["java","-jar", "api.jar"] \ No newline at end of file From 6f9ac12db47ccf8b4dca8a475ababe4af3d37b01 Mon Sep 17 00:00:00 2001 From: kyoohyun Date: Wed, 1 Feb 2023 16:11:58 +0900 Subject: [PATCH 2/2] =?UTF-8?q?GM-176=20GithubAction=20CI=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=8C=8C=EC=9D=BC=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d63bfc9..4cfda31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,17 @@ name: Java CI with Gradle on: - pull_request: permissions: contents: read +env: + DOCKER_IMAGE: ghcr.io/${{ github.actor }}/gaaji-auth-service + VERSION: ${{ github.sha }} + + jobs: build: