OH2-418 | Orthanc Integration #2131
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
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI with Maven | |
on: [push, pull_request] | |
env: | |
MAVEN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Debug GitHub variables | |
run: | | |
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" | |
echo "GITHUB_HEAD_REPOSITORY: ${GITHUB_HEAD_REPOSITORY}" | |
echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}" | |
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}" | |
echo "GITHUB_REF: ${GITHUB_REF}" | |
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}" | |
- name: Determine PR source branch and fork repository | |
id: vars | |
run: | | |
# Set default FORK_REPO and BRANCH_NAME values. | |
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" | |
if [[ "$GITHUB_EVENT_NAME" == "push" && "$GITHUB_REPOSITORY" == "informatici/openhospital-api" ]]; then | |
# For pushes to the main repository, default to the main core repo | |
FORK_REPO="informatici/openhospital-core" | |
else | |
# For pull requests or other pushes, use the contributor fork if applicable | |
if [[ -n "$GITHUB_HEAD_REPOSITORY" ]]; then | |
FORK_REPO="$GITHUB_HEAD_REPOSITORY" | |
else | |
# Check if the actor's repo exists with the branch | |
FORK_REPO="${GITHUB_ACTOR}/openhospital-core" | |
CHECK_BRANCH_URL="https://github.com/$FORK_REPO/tree/$BRANCH_NAME" | |
echo "Checking branch existence with: curl -s -o /dev/null -w \"%{http_code}\" $CHECK_BRANCH_URL" | |
if curl -s -o /dev/null -w "%{http_code}" "$CHECK_BRANCH_URL" | grep -q "200"; then | |
echo "Branch $BRANCH_NAME exists in $FORK_REPO." | |
else | |
# Fallback to the main repository if the branch doesn’t exist in the fork | |
FORK_REPO="informatici/openhospital-core" | |
fi | |
fi | |
fi | |
# Export FORK_REPO and BRANCH_NAME to GITHUB_ENV for the next step | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
echo "FORK_REPO=$FORK_REPO" >> $GITHUB_ENV | |
- name: Log variables | |
run: | | |
echo "FORK_REPO: ${{ env.FORK_REPO }}" | |
echo "BRANCH_NAME: ${{ env.BRANCH_NAME }}" | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
java-package: jdk | |
- name: Checkout core | |
run: | | |
git clone --depth=1 --no-single-branch https://github.com/${{ env.FORK_REPO }}.git openhospital-core | |
pushd openhospital-core | |
git checkout -B ${{ env.BRANCH_NAME }} origin/${{ env.BRANCH_NAME }} || git checkout develop | |
popd | |
- name: Install core | |
run: | | |
pushd openhospital-core | |
mvn install -DskipTests=true | |
popd | |
- name: Build with Maven | |
run: mvn install |