Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbontyes authored Jul 10, 2024
0 parents commit d625af9
Show file tree
Hide file tree
Showing 119 changed files with 10,330 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/actions/upload-maven-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Upload MSf artifacts

description: 'Custom action used to upload MSF artifacts ie execution ready .zip files to GitHub'

inputs:
artifact-path:
description: 'Path to the artifact(s) to upload'
required: false
default: ''
artifact-name:
description: 'Name of the artifact(s) to upload'
required: false
default: 'distro'
maven-server-username:
description: 'username of the server for maven settings.xml file'
required: true
default: ''
maven-server-token:
description: 'token of the server for maven settings.xml file'
required: true
default: ''

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
clean: false

- uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'adopt'

- name: Set settings.xml
uses: s4u/[email protected]
with:
servers: |
[{
"id": "msf-ocg-github-lime-emr",
"username": "${{ inputs.maven-server-username }}",
"password": "${{ inputs.maven-server-token }}"
}]
# - name: Publish ${{ inputs.artifact-name }} maven artifacts
# working-directory: ${{ inputs.artifact-path }}
# run: 'mvn --batch-mode clean deploy'
# shell: bash

- name: Get MSF ${{ inputs.artifact-name }} version
working-directory: ${{ inputs.artifact-path }}
id: get_version
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
shell: bash

- name: Get MSF ${{ inputs.artifact-name }} artifactId
working-directory: ${{ inputs.artifact-path }}
id: get_artifactId
run: echo "ARTIFACTID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV
shell: bash

- name: Upload MSF ${{ inputs.artifact-name }} GitHub
if: success()
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACTID }}-${{ env.VERSION }}
path: ${{ inputs.artifact-path }}/target/${{ env.ARTIFACTID }}-${{ env.VERSION }}.zip
compression-level: 0
overwrite: true
if-no-files-found: error
64 changes: 64 additions & 0 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build all configurations and deploy

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build-and-publish:
permissions:
contents: read
packages: write
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/[email protected]
with:
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

- 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 }}"

- 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 }}"

- 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 }}"
120 changes: 120 additions & 0 deletions .github/workflows/configuration-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
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/[email protected]
with:
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 }}"
Loading

0 comments on commit d625af9

Please sign in to comment.