Skip to content

Build, validate configuration and deploy #39

Build, validate configuration and deploy

Build, validate configuration and deploy #39

name: Build, validate configuration and deploy
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Set settings.xml
uses: s4u/maven-settings-action@v3.0.0
with:
mirrors: |
[{
"id": "mks-nexus-public",
"name": "ozone-mirror",
"mirrorOf": "com.ozonehis*",
"url": "https://nexus.mekomsolutions.net/repository/maven-public/"
}]
servers: |
[{
"id": "msf-ocg-github-lime-emr",
"username": "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}",
"password": "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"
}]
- name: Build and Test
run: mvn --batch-mode --update-snapshots --activate-profiles validator clean package
release:
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: build
outputs:
directories: ${{ steps.check_dir.outputs.directories }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Trigger build job based on directory
id: check_dir
run: |
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) == *"distro"* ]]; then
echo "Triggering the 'release-distro' job and its children"
DIRECTORIES=("distro", "iraq", "mosul")
echo "directories=${DIRECTORIES}" >> $GITHUB_OUTPUT
elif [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) == *"iraq"* ]]; then
echo "Triggering the 'release-iraq' job and its children"
DIRECTORIES=("iraq", "mosul")
echo "directories=${DIRECTORIES}" >> $GITHUB_OUTPUT
elif [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) == *"mosul"* ]]; then
echo "Triggering the 'release-mosul' job"
DIRECTORIES=("mosul")
echo "directories=${DIRECTORIES}" >> $GITHUB_OUTPUT
else
echo "No relevant directory changes, skipping build job"
DIRECTORIES=()
echo "directories=${DIRECTORIES}" >> $GITHUB_OUTPUT
fi
release-distro:
needs: release
if: contains(needs.release.outputs.directories, 'distro')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Publish MSF distro artifacts to GitHub
uses: ./.github/actions/upload-maven-artifacts
with:
artifact-name: "distro"
artifact-path: "${{ github.workspace }}/distro"
maven-server-username: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}"
maven-server-token: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"
release-iraq:
needs: [release, release-distro]
if: |
( always() && !failure() ) &&
contains(needs.release.outputs.directories, 'iraq')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Publish MSF Mosul to artifacts GitHub
uses: ./.github/actions/upload-maven-artifacts
with:
artifact-name: "Iraq"
artifact-path: "${{ github.workspace }}/countries/iraq"
maven-server-username: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}"
maven-server-token: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"
release-mosul:
needs: [release, release-iraq]
if: |
( always() && !failure() ) &&
contains(needs.release.outputs.directories, 'mosul')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Publish MSF Iraq artifacts to GitHub
uses: ./.github/actions/upload-maven-artifacts
with:
artifact-name: "Mosul"
artifact-path: "${{ github.workspace }}/sites/mosul"
maven-server-username: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_USERNAME }}"
maven-server-token: "${{ secrets.MAVEN_GITHUB_ACTIONS_DEPLOY_TOKEN }}"