From 3f27e9c4711373ff69b064d046eecb179471accd Mon Sep 17 00:00:00 2001 From: thegreystone Date: Tue, 30 Jul 2024 02:34:08 +0200 Subject: [PATCH] Adding github CI action --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a16a08b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: Slogan Generator CI/CD + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java-version: [17] # Currently only 17, but easily extendable + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + run: ./mvnw clean package + - name: Run tests + run: ./mvnw test + + docker: + needs: build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./src/main/docker/Dockerfile.jvm + platforms: linux/amd64,linux/arm64 + push: true + tags: greystone/slogan-generator:latest diff --git a/README.md b/README.md index 1b1697e..f78db12 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![CI](https://github.com/thegreystone/slogan-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/thegreystone/slogan-generator/actions/workflows/ci.yml) # slogan-generator This is a simple slogan text or image generator. I wanted to replace the one I have on my homepage,