Browse Source

add gha workflow

Daniel Bohry 1 month ago
parent
commit
a1bb7f39da
2 changed files with 67 additions and 0 deletions
  1. 23 0
      .github/workflows/build.yml
  2. 44 0
      .github/workflows/buildAndRelease.yml

+ 23 - 0
.github/workflows/build.yml

@@ -0,0 +1,23 @@
+name: Build and Test
+
+on:
+  pull_request:
+    branches: [ main ]
+
+jobs:
+
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v3
+    - name: Set up JDK 25
+      uses: actions/setup-java@v3
+      with:
+        java-version: '25'
+        distribution: 'temurin'
+    - name: Build jar
+      run: chmod +x ./gradlew && ./gradlew clean build
+    - name: Run tests
+      run: ./gradlew test

+ 44 - 0
.github/workflows/buildAndRelease.yml

@@ -0,0 +1,44 @@
+name: Release
+
+on:
+  push:
+    branches: [ main ]
+
+jobs:
+  build-and-test:
+    name: Build and Test
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up JDK
+        uses: actions/setup-java@v3
+        with:
+          java-version: '25'
+          distribution: 'temurin'
+      - name: Build with Gradle
+        run: chmod +x ./gradlew && ./gradlew clean build test
+
+  dockerize:
+    name: Dockerize Application
+    needs: build-and-test
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up JDK
+        uses: actions/setup-java@v3
+        with:
+          java-version: '25'
+          distribution: 'temurin'
+      - name: Build
+        run: ./gradlew build
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v2
+      - name: Login to Docker Hub
+        uses: docker/login-action@v2
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+      - name: Build and Push Image
+        run: |
+          docker buildx create --use
+          docker buildx build --platform linux/amd64,linux/arm64 -t dbohry/knotes:latest --push .