Build and Publish OpenMRS #673
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: Build and Publish OpenMRS | |
on: | |
push: | |
branches: | |
- snomed-master | |
- 'snomed-release-*' | |
tags: | |
- 'snomed-[0-9]+.[0-9]+.[0-9]+' | |
paths-ignore: | |
- "**.md" | |
workflow_dispatch: | |
jobs: | |
build-publish-docker: | |
name: Build & Publish Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build with Maven | |
run: | | |
./mvnw --no-transfer-progress -U clean install | |
env: | |
USER_NAME: ${{ secrets.USERNAME }} | |
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Docker Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: package/docker/openmrs/Dockerfile | |
push: true | |
tags: bahmni/openmrs:snomed-${{ github.run_number }},bahmni/openmrs:snomed-latest | |
trigger: | |
name: Trigger Deployment Workflow | |
needs: | |
- build-publish-docker | |
runs-on: ubuntu-latest | |
env: | |
ORG_NAME: Bahmni | |
REPOSITORY_NAME: snomed-bahmni-docker | |
ENVIRONMENT: dev | |
steps: | |
- name: Create workflow_dispatch | |
run: | | |
trigger_result=$(curl -s -o trigger_response.txt -w "%{http_code}" -X POST -H "Accept: application/vnd.github.v3+json" -H 'authorization: Bearer ${{ secrets.BAHMNI_PAT }}' https://api.github.com/repos/${ORG_NAME}/${REPOSITORY_NAME}/actions/workflows/snomed-deploy.yml/dispatches -d '{"ref":"snomed-master","inputs":{"environment":"'"${ENVIRONMENT}"'"}}') | |
if [ $trigger_result == 204 ];then | |
echo "Trigger to $ORG_NAME/$REPOSITORY_NAME Success" | |
else | |
echo "Trigger to $ORG_NAME/$REPOSITORY_NAME Failed" | |
cat trigger_response.txt | |
exit 1 | |
fi |