From 142424e68990e737589564f8cd3f91e0eeb7b3b4 Mon Sep 17 00:00:00 2001 From: ybchar Date: Thu, 4 Jul 2024 01:13:05 +0900 Subject: [PATCH] chore: dev workflow test --- .github/workflows/develop-build-deploy.yml | 80 ++++++++++++++++++++++ Dockerfile | 4 ++ Dockerrun.aws.json | 13 ++++ 3 files changed, 97 insertions(+) create mode 100644 .github/workflows/develop-build-deploy.yml create mode 100644 Dockerfile create mode 100644 Dockerrun.aws.json diff --git a/.github/workflows/develop-build-deploy.yml b/.github/workflows/develop-build-deploy.yml new file mode 100644 index 00000000..d59fc470 --- /dev/null +++ b/.github/workflows/develop-build-deploy.yml @@ -0,0 +1,80 @@ +name: Pull Request on Check +on: + push: + branches: + - "chore/#24-elastic-beanstalk-deploy" + +env: + DOCKERHUB_IMAGE_NAME: walwal-server + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [ 17 ] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + distribution: 'zulu' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + # Gradle 빌드 + - name: Build with Gradle + id: gradle + uses: gradle/gradle-build-action@v3 + with: + arguments: | + build + --scan + cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} + + - name: Docker build + run: | + docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }} . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }} + + - name: Current Time + uses: gerred/current-time@v1.0.0 + id: current-time + + - name: Replace string + uses: frabert/replace-string-action@v2.1 + id: format-time + with: + pattern: '[:\.]+' + string: "${{ steps.current-time.outputs.time }}" + replace-with: '-' + flags: 'g' + + # 슬랙으로 빌드 스캔 결과 전송 + - name: Send to slack + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "text": "Gradle Build Scan Report of ${{ github.workflow }}: ${{ steps.gradle.outputs.build-scan-url }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + # Beanstalk 플러그인을 사용 + # 미리 생성해둔 IAM 인증키를 사용 + - name: Beanstalk Deploy + uses: einaregilsson/beanstalk-deploy@v20 + with: + aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + application_name: "walwal-server" + environment_name: "walwal-server-env" + version_label: "github-action-${{ steps.format-time.outputs.replaced }}" + region: ap-northeast-2 + deployment_package: Dockerrun.aws.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d5b0b605 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM azul/zulu-openjdk:17-latest +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/Dockerrun.aws.json b/Dockerrun.aws.json new file mode 100644 index 00000000..238b8cd5 --- /dev/null +++ b/Dockerrun.aws.json @@ -0,0 +1,13 @@ +{ + "AWSEBDockerrunVersion": "1", + "Image": { + "Name": "olderstonebed/walwal-server:latest", + "Update": "true" + }, + "Ports": [ + { + "ContainerPort": 8080, + "HostPort": 5000 + } + ] +}