115 lines
3.2 KiB
YAML
115 lines
3.2 KiB
YAML
name: Build & Push Native Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-actor:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
allowed: ${{ steps.check.outputs.allowed }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- id: check
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
|
echo "allowed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
COMMIT_AUTHOR=$(git log -1 --format='%an')
|
|
if [[ "$COMMIT_AUTHOR" == "TeamCity" ]]; then
|
|
echo "allowed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "allowed=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
fi
|
|
|
|
build-and-push:
|
|
needs: check-actor
|
|
if: needs.check-actor.outputs.allowed == 'true'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
strategy:
|
|
matrix:
|
|
module:
|
|
- account
|
|
- bot-platform
|
|
- coordinator
|
|
- core
|
|
- io
|
|
- official-bots
|
|
- rule
|
|
- store
|
|
- ws
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up GraalVM
|
|
uses: graalvm/setup-graalvm@v1
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'graalvm-community'
|
|
native-image-job-reports: 'true'
|
|
|
|
- name: Cache Gradle packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
restore-keys: gradle-${{ runner.os }}-
|
|
|
|
- name: Read version from versions.env
|
|
id: version
|
|
run: |
|
|
if [ -f "modules/${{ matrix.module }}/versions.env" ]; then
|
|
source modules/${{ matrix.module }}/versions.env
|
|
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version=latest" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Build native binary
|
|
run: ./gradlew :modules:${{ matrix.module }}:build -x test -Dquarkus.native.enabled=true -Dquarkus.package.jar.enabled=false -Dquarkus.profile=deployed --no-daemon
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/now-chess/now-chess-systems/${{ matrix.module }}
|
|
tags: |
|
|
type=raw,value=${{ steps.version.outputs.version }}
|
|
type=raw,value=latest
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: modules/${{ matrix.module }}/src/main/docker/Dockerfile.native
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha,scope=${{ matrix.module }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.module }}
|