Skip to content

Commit

Permalink
Publish action also as Docker image (#4)
Browse files Browse the repository at this point in the history
* Added action to publish docker image

* Fixes for entrypoint.sh

* Version bump
  • Loading branch information
pmanko authored Jan 22, 2022
1 parent 1ce0c95 commit 6a4254d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,49 @@ on:
release:
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Steps represent a sequence of tasks that will be executed as part of the job
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Docker image
uses: docker/build-push-action@v2
if: github.event_name == 'release'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

test:
runs-on: ubuntu-latest
steps:
- name: Wait For OpenMRS
uses: I-TECH-UW/wait-for-openmrs-action@v0.2.3
uses: I-TECH-UW/wait-for-openmrs-action@v0.3.0
with:
target-url: http://isanteplusdemo.com/openmrs
interval: 10 # default is 1000
Expand Down
11 changes: 6 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ while :; do
rest=0

if [ $fhir -eq 0 ]; then
response=$(curl -u admin:Admin123 -s -w "\n%{http_code}" $url/ws/fhir2/R4/metadata?_format=json)
response=$(curl --max-time 1 -u admin:Admin123 -s -w "\n%{http_code}" $url/ws/fhir2/R4/metadata?_format=json)
response=(${response[@]}) # convert to array
code=${response[-1]} # get last element (last line)

Expand All @@ -26,12 +26,12 @@ while :; do

if [[ "${body[0]}" == *"CapabilityStatement"* ]]; then
echo "Got FHIR Metadata after $(($(date +%s)-$START_TIME)) seconds!"
fhir=true
fhir=1
fi
fi

if [ $rest -eq 0 ]; then
response=$(curl -u admin:Admin123 -s -w "\n%{http_code}" $url/ws/rest/v1/session)
response=$(curl --max-time 1 -u admin:Admin123 -s -w "\n%{http_code}" $url/ws/rest/v1/session)
response=(${response[@]}) # convert to array

code=${response[-1]} # get last element (last line)
Expand All @@ -40,11 +40,12 @@ while :; do

if [[ "$code" == "200" ]]; then
echo "Got REST API after $(($(date +%s)-$START_TIME)) seconds!"
rest=true
rest=1
fi
fi

if [[ $rest && $fhir ]]; then
if [[ $rest -eq 1 && $fhir -eq 1 ]]; then
echo "Exiting!"
exit 0
else
echo "Still waiting..."
Expand Down

0 comments on commit 6a4254d

Please sign in to comment.