ci(): added basic CI: build, test, docker build & push

This commit is contained in:
ITQ
2026-04-26 19:25:43 +03:00
parent 910a382679
commit c609bd1e3c
4 changed files with 155 additions and 28 deletions
+50
View File
@@ -0,0 +1,50 @@
name: Build & Test
on:
workflow_call:
outputs:
artifact-name:
description: "Uploaded artifact name for downstream jobs"
value: ${{ jobs.build.outputs.artifact-name }}
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
artifact-name: ${{ steps.meta.outputs.artifact-name }}
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
cache: gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build
run: ./gradlew clean assemble --stacktrace --no-daemon
- name: Test
run: ./gradlew test --stacktrace --no-daemon
- name: Set artifact name
id: meta
run: echo "artifact-name=build-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_OUTPUT"
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ steps.meta.outputs.artifact-name }}
path: |
build/libs/**
build/reports/**
build/test-results/**
retention-days: 7
if-no-files-found: error
+31
View File
@@ -0,0 +1,31 @@
name: CI
run-name: "${{ github.ref_name }} - ${{ github.event_name }} by @${{ github.actor }}"
on:
push:
branches: [develop, main]
tags: ["v*"]
pull_request:
branches: [develop, main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build & Test
uses: ./.github/workflows/build.yaml
permissions:
contents: read
docker:
name: Docker
needs: build
uses: ./.github/workflows/docker.yaml
permissions:
contents: read
packages: write
with:
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
secrets: inherit
+74
View File
@@ -0,0 +1,74 @@
name: Docker Build & Push
on:
workflow_call:
inputs:
push:
description: "Push image to GHCR"
type: boolean
required: true
outputs:
image-digest:
description: "Pushed image digest (sha256:…)"
value: ${{ jobs.docker.outputs.image-digest }}
image-tags:
description: "Comma-separated list of applied tags"
value: ${{ jobs.docker.outputs.image-tags }}
jobs:
docker:
name: Docker Build & Push
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
image-digest: ${{ steps.build-push.outputs.digest }}
image-tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Validate Dockerfile
if: inputs.push == false
uses: docker/build-push-action@v7
with:
context: .
file: ./Containerfile
call: check
- name: Log in to GHCR
if: inputs.push == true
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
if: inputs.push == true
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=ref,event=pr
type=sha,prefix=sha-
- name: Build and push image
if: inputs.push == true
id: build-push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max
-28
View File
@@ -1,28 +0,0 @@
name: CI Build
on:
pull_request:
branches: [ develop, main ]
push:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build project
run: ./gradlew build -x test