Merge pull request #671 from Bahmni/drug-chart-schedule-tasks #421
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 | |
on: | |
push: | |
branches: | |
- Bahmni-IPD-master | |
paths-ignore: | |
- "**.md" | |
workflow_dispatch: | |
jobs: | |
Trivy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Trivy Scan | |
run: | | |
wget -q https://raw.githubusercontent.com/Bahmni/bahmni-infra-utils/main/trivy_scan.sh && chmod +x trivy_scan.sh | |
./trivy_scan.sh | |
rm trivy_scan.sh | |
build-publish-docker: | |
name: Build & Publish Docker Image | |
runs-on: ubuntu-latest | |
needs: Trivy | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 10.16.3 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.x | |
- name: Use Ruby 2.5 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.5 | |
- run: npm install -g bower | |
- run: npm install -g grunt-cli | |
- run: gem install compass | |
- run: npm install --global yarn | |
- name: micro-frontends | install dependencies | |
working-directory: micro-frontends | |
run: yarn install --frozen-lock-file | |
- name: micro-frontends | test | |
working-directory: micro-frontends | |
run: yarn test:ci | |
- name: micro-frontends | build | |
working-directory: micro-frontends | |
run: yarn build | |
- name: Package | |
run: cd ui && yarn cache clean && /bin/bash ./scripts/package.sh | |
- 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/Dockerfile | |
push: true | |
tags: bahmni/bahmni-web:ipd-${{ github.run_number }},bahmni/bahmni-web:ipd | |
trigger-workflow: | |
name: Trigger workflow to deploy to Docker env | |
needs: | |
- build-publish-docker | |
- Trivy | |
runs-on: ubuntu-latest | |
env: | |
EVENT_TYPE: openmrs-module-bahmniapps-event | |
steps: | |
- name: Create repository_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.IPD_PAT }}' https://api.github.com/repos/${{ secrets.IPD_ORG_NAME }}/${{ secrets.IPD_REPOSITORY_NAME }}/dispatches -d '{"event_type":"'"${EVENT_TYPE}"'"}') | |
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 |