Files
shot-crafter-calculator/.gitea/workflows/ci.yml
T
darroyo f3af0f8975
CI / Build JVM (push) Failing after 2m56s
CI / Build Native (push) Failing after 21m20s
CI / Build & Push Native Image (push) Has been skipped
fix(ci): install Maven in each job (runner has no mvn binary)
The runner has Java (via setup-java) but no Maven. Add an
Install Maven step to build-jvm and build-native that downloads
Maven 3.9.6 from Apache to runner.workspace/.maven and adds it
to the PATH via $GITHUB_PATH. Idempotent: the if-guard skips
redownload if the binary already exists on the runner.
2026-08-12 16:33:02 -04:00

151 lines
4.2 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-jvm:
name: Build JVM
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: maven
- name: Install Maven
env:
MAVEN_VERSION: 3.9.6
MAVEN_HOME: ${{ runner.workspace }}/.maven
run: |
mkdir -p "$MAVEN_HOME"
if [ ! -x "$MAVEN_HOME/bin/mvn" ]; then
curl -fsSL "https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" | tar -xz -C "$MAVEN_HOME" --strip-components=1
fi
echo "$MAVEN_HOME/bin" >> "$GITHUB_PATH"
mvn --version
- name: Cache Node + npm
uses: actions/cache@v4
with:
path: |
target/node
src/frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Build (JVM)
run: mvn package -B -DskipTests
- name: Upload JVM artifact
uses: actions/upload-artifact@v4
with:
name: shot-crafter-calculator-jvm
path: target/quarkus-app/
build-native:
name: Build Native
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: maven
- name: Install Maven
env:
MAVEN_VERSION: 3.9.6
MAVEN_HOME: ${{ runner.workspace }}/.maven
run: |
mkdir -p "$MAVEN_HOME"
if [ ! -x "$MAVEN_HOME/bin/mvn" ]; then
curl -fsSL "https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" | tar -xz -C "$MAVEN_HOME" --strip-components=1
fi
echo "$MAVEN_HOME/bin" >> "$GITHUB_PATH"
mvn --version
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm'
java-version: '21'
components: 'native-image'
- name: Cache Node + npm
uses: actions/cache@v4
with:
path: |
target/node
src/frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Build (Native)
run: mvn package -Pnative -B -DskipTests
- name: Upload Native binary
uses: actions/upload-artifact@v4
with:
name: shot-crafter-calculator-runner
path: target/shot-crafter-calculator-1.0.0-runner
docker-native:
name: Build & Push Native Image
runs-on: ubuntu-latest
needs: build-native
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download native binary
uses: actions/download-artifact@v4
with:
name: shot-crafter-calculator-runner
path: target/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: gitea.danielarroyo.cl
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract short SHA
id: meta
run: echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: |
gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:latest
gitea.danielarroyo.cl/proyectos/shot-crafter-calculator:${{ steps.meta.outputs.short_sha }}
platforms: linux/amd64