From e0438ff26d879f254d93eeb87cdc09b4924b7345 Mon Sep 17 00:00:00 2001 From: cypsyco Date: Tue, 23 Jan 2024 00:16:50 +0900 Subject: [PATCH] github actions test --- .github/workflows/cicd.yml | 36 ++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 30 ------------------------------ Dockerfile | 5 +++++ 3 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/cicd.yml delete mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..9752686 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,36 @@ +name: CICD + +on: + push: + branches: [main] + +jobs: + build: + runs-on: [ubuntu-latest] + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Build Project + run: mvn clean install -DskipTests + - name: Login to docker hub + run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} + - name: Build docker image + run: docker build -t integrationninjas/springboot-example . + - name: Publish image to docker hub + run: docker push integrationninjas/springboot-example:latest + + deploy: + needs: build + runs-on: [ip-172-31-8-60] + steps: + - name: Pull Image from docker hub + run: docker pull integrationninjas/springboot-example:latest + - name: Delete old container + run: docker rm -f springboot-example-container + - name: Run docker container + run: docker run -d -p 8080:8080 --name springboot-example-container integrationninjas/springboot-example \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1d8305e..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: signal server CI/CD - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - S3_BUCKET_NAME: signal-deploy - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew clean build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1518563 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM eclipse-temurin:17-jdk-alpine +WORKDIR /app +COPY target/springboot-example.jar springboot-example.jar +EXPOSE 8080 +CMD ["java", "-jar", "springboot-example.jar"] \ No newline at end of file