feat: Add Gitea pipelines for frontend and backend
This commit is contained in:
99
.gitea/workflows/backend.yaml
Normal file
99
.gitea/workflows/backend.yaml
Normal file
@@ -0,0 +1,99 @@
|
||||
name: Backend CI/CD
|
||||
run-name: ${{ gitea.actor }} triggered backend pipeline on ${{ gitea.ref_name }}
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'legalconsenthub-backend/**'
|
||||
- '.gitea/workflows/backend.yaml'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'legalconsenthub-backend/**'
|
||||
- '.gitea/workflows/backend.yaml'
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./legalconsenthub-backend
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Gradle cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
legalconsenthub-backend/.gradle
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build application
|
||||
run: ./gradlew build -x test
|
||||
|
||||
- name: Run ktlint check
|
||||
run: ./gradlew ktlintCheck
|
||||
|
||||
- name: Run tests with Testcontainers
|
||||
run: ./gradlew test
|
||||
env:
|
||||
SPRING_PROFILES_ACTIVE: testcontainers
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.lugnas.de
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ gitea.token }}
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: gitea.lugnas.de/${{ gitea.repository_owner }}/legalconsenthub-backend
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' }}
|
||||
type=sha,prefix=,format=long
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./legalconsenthub-backend
|
||||
push: ${{ gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Image built successfully
|
||||
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
||||
run: |
|
||||
echo "✅ Docker image built and pushed successfully"
|
||||
echo "📦 Image: gitea.lugnas.de/${{ gitea.repository_owner }}/legalconsenthub-backend:latest"
|
||||
echo "📦 Image: gitea.lugnas.de/${{ gitea.repository_owner }}/legalconsenthub-backend:${{ gitea.sha }}"
|
||||
|
||||
- name: Dry-run completed
|
||||
if: gitea.event_name == 'pull_request'
|
||||
run: |
|
||||
echo "✅ Dry-run build completed successfully (image not pushed)"
|
||||
|
||||
Reference in New Issue
Block a user