ci: add gitea image publishing workflows
This commit is contained in:
111
.gitea/workflows/build-snapshot.yaml
Normal file
111
.gitea/workflows/build-snapshot.yaml
Normal file
@@ -0,0 +1,111 @@
|
||||
name: Snapshot Docker Image Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
verify-and-package:
|
||||
if: github.repository != 'templates/mono-app-with-db'
|
||||
runs-on: java-node-24
|
||||
env:
|
||||
GRADLE_USER_HOME: /opt/hostedtoolcache/gradle/${{ github.repository }}
|
||||
|
||||
steps:
|
||||
- name: 1. Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 2. Prepare Gradle cache and Docker access
|
||||
run: |
|
||||
sudo install -d -m 0755 -o "$(id -u)" -g "$(id -g)" "$GRADLE_USER_HOME"
|
||||
sudo chgrp "$(id -g)" /var/run/docker.sock
|
||||
sudo chmod g+rw /var/run/docker.sock
|
||||
|
||||
- name: 3. Verify and stage with Gradle
|
||||
run: |
|
||||
./gradlew --no-daemon --console=plain check stageFatJar
|
||||
|
||||
- name: 4. Upload test reports
|
||||
if: always()
|
||||
id: upload-test-reports
|
||||
uses: christopherhx/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: test-reports
|
||||
path: |
|
||||
build/reports/tests/test/**
|
||||
build/test-results/test/**/*.xml
|
||||
if-no-files-found: warn
|
||||
retention-days: 7
|
||||
|
||||
- name: 5. Output test report artifact URL
|
||||
if: always()
|
||||
run: |
|
||||
echo "Test reports: ${{ steps.upload-test-reports.outputs.artifact-url }}"
|
||||
|
||||
- name: 6. Upload staged fat jar
|
||||
uses: christopherhx/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: application-fat-jar
|
||||
path: build/ci/server.jar
|
||||
retention-days: 1
|
||||
compression-level: 0
|
||||
|
||||
build-and-publish-snapshot:
|
||||
if: github.repository != 'templates/mono-app-with-db'
|
||||
runs-on: java-node-24
|
||||
needs: verify-and-package
|
||||
env:
|
||||
REGISTRY: git.dslan.at
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
|
||||
steps:
|
||||
- name: 1. Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 2. Download staged fat jar
|
||||
uses: christopherhx/gitea-download-artifact@v4
|
||||
with:
|
||||
name: application-fat-jar
|
||||
path: ./build/ci
|
||||
|
||||
- name: 3. Prepare Docker access
|
||||
run: |
|
||||
sudo chgrp "$(id -g)" /var/run/docker.sock
|
||||
sudo chmod g+rw /var/run/docker.sock
|
||||
|
||||
- name: 4. Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.11.0
|
||||
with:
|
||||
driver: docker-container
|
||||
driver-opts: network=host
|
||||
|
||||
- name: 5. Read version and set snapshot tag
|
||||
id: meta
|
||||
run: |
|
||||
VERSION_BASE=$(cat VERSION)
|
||||
LAST_CHANGED=$(git log -1 --format=%H VERSION)
|
||||
COUNT=$(git rev-list ${LAST_CHANGED}..HEAD --count)
|
||||
SNAPSHOT_TAG="${VERSION_BASE}-SNAPSHOT-$((COUNT + 1))"
|
||||
echo "tag_version=$SNAPSHOT_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 6. Log in to the Gitea Container Registry
|
||||
uses: docker/login-action@v3.6.0
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.PR_USER }}
|
||||
password: ${{ secrets.PR_PASSWORD }}
|
||||
|
||||
- name: 7. Build and push the Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./build/ci
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ steps.meta.outputs.tag_version }}
|
||||
${{ env.REGISTRY }}/${{ env.REPOSITORY }}:snapshot-latest
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY }}:buildcache-snapshot
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY }}:buildcache-snapshot,mode=max
|
||||
Reference in New Issue
Block a user