Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Spring Test Initializers | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build and Release | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15.4-alpine3.18 | |
env: | |
POSTGRES_USER: ci-user | |
POSTGRES_PASSWORD: ci-pass | |
POSTGRES_DB: testsupport | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
keycloak-it: | |
image: "jboss/keycloak:11.0.0" | |
env: | |
KEYCLOAK_USER: admin | |
KEYCLOAK_PASSWORD: admin | |
DB_VENDOR: h2 | |
ports: | |
- 18080:8080 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: temurin | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Set up Maven cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build | |
run: mvn -B -ntp clean install | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
POSTGRES_USER: ci-user | |
POSTGRES_PASSWORD: ci-pass | |
POSTGRES_DB: testsupport | |
- name: Release | |
if: github.event_name == 'release' && github.event.action == 'published' | |
run: | | |
# Assign the tag name to a variable | |
tag_name="${{ github.event.release.tag_name }}" | |
# Check if the tag name starts with 'v' and strip it if present | |
if [[ $tag_name == v* ]]; then | |
tag_name="${tag_name:1}" | |
fi | |
git config --global user.email "[email protected]" | |
git config --global user.name "DenktMit eG" | |
mvn -Drevision=${tag_name} -Dchangelist= -B -ntp -DskipTests -Pci-cd clean deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |