Files
gitea-actions/.github/workflows/maven-publish.yml
T
Workflow config file is invalid. Please check your config file: read workflow: yaml: unmarshal errors: line 133: mapping key "env" already defined at line 95

136 lines
4.8 KiB
YAML

# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Publish
on:
workflow_call:
inputs:
MVN_SETTINGS_XML:
required: true
type: string
JAVA_VERSION:
required: true
type: string
secrets:
AWS_CA_TOKEN:
required: true
DEVOPS_ACCESS_TOKEN:
required: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# Uncomment this if feature branch for curh-schemas is needed
# - name: Checkout tools repo feature branch
# uses: actions/checkout@v4
# continue-on-error: true
# with:
# repository: curh-backend/curh-schemas
# path: curh-schemas
# ref: ${{ github.ref }}
# token: ${{ secrets.DEVOPS_ACCESS_TOKEN }}
- name: Checkout tools repo main branch
uses: actions/checkout@v4
env:
check_token: ${{ secrets.DEVOPS_ACCESS_TOKEN }}
if: ${{ env.check_token != '' }}
with:
repository: curh-backend/curh-schemas
path: curh-schemas
ref: main
token: ${{ secrets.DEVOPS_ACCESS_TOKEN }}
- name: Unpack curh schemas
if: ${{ hashFiles('curh-schemas/pom.xml') != '' }}
run: |
ls -al
cd curh-schemas/src/main/resources
mkdir -p /opt/rizik
cp -R xsd/ /opt/rizik/
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: '3.9.9'
- name: Print branch
run: |
echo "Running on branch: $BRANCH"
env:
BRANCH: ${{ github.ref }}
- name: Set up JDK 21
if: github.ref == 'refs/heads/feature/T2900-java21' || github.ref == 'refs/heads/feature/T2900-java-21'
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Set up JDK from ENV
if: github.ref != 'refs/heads/feature/T2900-java21' && github.ref != 'refs/heads/feature/T2900-java-21'
uses: actions/setup-java@v4
with:
java-version: '${{ inputs.JAVA_VERSION }}'
distribution: 'corretto'
- name: Create Maven settings
run: |
echo -e "$SETTINGS_XML" > ~/.m2/settings.xml
env:
SETTINGS_XML: ${{ inputs.MVN_SETTINGS_XML }}
- name: Deploy artifacts and sources
run: |
mvn clean source:jar-no-fork deploy -U -e --file pom.xml -DrepositoryId=pravila--pravila-maven -DtrimStackTrace=false -Dsurefire.useFile=false -Dsurefire.printSummary=true
env:
GITHUB_TOKEN: ${{ github.token }}
CODEARTIFACT_AUTH_TOKEN: ${{ secrets.AWS_CA_TOKEN }}
TESTCONTAINERS_HOST_OVERRIDE: "172.17.0.1"
TESTCONTAINERS_RYUK_DISABLED: "true"
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/docker.sock"
# - name: Upload snapshot to nexus
# run: |
# GROUP_ID=$(mvn help:evaluate -Dexpression="project.groupId" -q -DforceStdout)
# ARTIFACT_ID=$(mvn help:evaluate -Dexpression="project.artifactId" -q -DforceStdout)
# VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
# FINAL_NAME=$(mvn help:evaluate -Dexpression="project.build.finalName" -q -DforceStdout)
# if [[ $VERSION == *SNAPSHOT ]];
# then
# echo "Version $VERSION is snapshot version, proceeding with upload to local-nexus snapshots"
# PACKAGING=$(mvn help:evaluate -Dexpression="project.packaging" -q -DforceStdout)
# echo "Uploading artifact for $GROUP_ID:$ARTIFACT_ID:$VERSION"
# if [ $PACKAGING == "pom" ];
# then
# echo "Packaging is pom, uploading pom.xml"
# mvn deploy:deploy-file \
# -Durl=https://devops.pravilanovait.hr/nexus/repository/maven-snapshots \
# -Dpackaging=pom -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID \
# -Dversion=$VERSION -DrepositoryId=local-nexus \
# -Dfile=pom.xml
# else
# echo "Packaging is $PACKAGING, uploading target/$ARTIFACT_ID-$VERSION.$PACKAGING"
# mvn deploy:deploy-file \
# -Durl=https://devops.pravilanovait.hr/nexus/repository/maven-snapshots \
# -Dpackaging=$PACKAGING -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID \
# -Dversion=$VERSION -DrepositoryId=local-nexus \
# -Dfile=target/$FINAL_NAME.$PACKAGING -DpomFile=pom.xml -DgeneratePom=false
# fi
# else
# echo "Version $VERSION is not snapshot version, not uploading to local-nexus snapshots"
# fi
env:
NEXUS_ADMIN_PASSWORD: ${{ secrets.NEXUS_ADMIN_PASSWORD }}
CODEARTIFACT_AUTH_TOKEN: ${{ secrets.AWS_CA_TOKEN }}