TASKPM/.forgejo/workflows/ubuntu_24.04.yml
2025-11-13 13:12:54 +01:00

113 lines
3.5 KiB
YAML

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Ubuntu 24.04 (Noble Numbat)
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Prevent cancellation of already running actions when pushing concurrently. Test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: docker
container:
image: ubuntu:24.04
services:
postgres:
image: postgres:16.0
env:
POSTGRES_USER: libreplan
POSTGRES_PASSWORD: libreplan
POSTGRES_DB: libreplandev
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# Define job-id
- name: actions prep
id: artifact-upload-prep
run: echo ::set-output name=artifact-id::$(git rev-parse --short=10 HEAD)
- name: install needed software
run: |
apt-get update
apt-get install -y postgresql-client nodejs git maven libpostgresql-jdbc-java
- name: Checkout code
uses: actions/checkout@v3
# Let's test caching maven stuff.
- name: Cache Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-
# Example 1: create extra database
- name: Create libreplandevtest database
env:
PGPASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
run: |
PGPASSWORD='libreplan' psql -h postgres -U libreplan -d postgres -v ON_ERROR_STOP=1 -c "CREATE DATABASE libreplandevtest;"
- name: Set up Java 8
uses: actions/setup-java@v4
with:
distribution: temurin # of adopt, zulu, corretto, liberica …
java-version: 8
- name: Verify Java version
run: java -version
# Determine maven version in container
- name: Show maven version number
run: mvn -v
- name: Wait for PostgreSQL to be ready
shell: bash
env:
PGPASSWORD: libreplan
run: |
for i in {1..30}; do
psql -h postgres -U libreplan -d libreplandev -c 'select 1' && break
sleep 2
done
# Yes, this looks ugly. But when cleanup over several lines mvn
# starts complaining: The POM for -DdataSource.url=jdbc:postgresql:jar://postgres is missing
# Starts thinking the datasource url is a pom it should download. Weird.
- name: Build with Maven
shell: bash
run: mvn clean install --no-transfer-progress -Ddefault.passwordsControl=false -Ddefault.exampleUsersDisabled=false -DdataSource.url=jdbc:postgresql://postgres:5432/libreplandev -DdataSource.user=libreplan -DdataSource.password=libreplan -DjdbcDriver.className=org.postgresql.Driver
# Upload the result
- name: Upload libreplan.war attempt 1
uses: actions/upload-artifact@v3
with:
name: libreplan.war
path: libreplan-webapp/target/libreplan-webapp.war
retention-days: 3
- name: Upload libreplan.war with git hash
uses: actions/upload-artifact@v3
with:
name: libreplan-${{ steps.artifact-upload-prep.outputs.artifact-id }}.war
path: libreplan-webapp/target/libreplan-webapp.war
retention-days: 3