From 6116243754370cca77b39689d5e87e097c5923f4 Mon Sep 17 00:00:00 2001 From: Siva Reddy Date: Thu, 21 Sep 2023 11:21:58 +0530 Subject: [PATCH] GHA Chnages --- .github/workflows/build_publish.yml | 73 ++++++++++------------------- .github/workflows/validate_pr.yml | 2 +- 2 files changed, 27 insertions(+), 48 deletions(-) diff --git a/.github/workflows/build_publish.yml b/.github/workflows/build_publish.yml index e3245322..c0585711 100644 --- a/.github/workflows/build_publish.yml +++ b/.github/workflows/build_publish.yml @@ -2,17 +2,15 @@ name: Build and Publish on: push: branches: - - master - - 'release-*' + - snomed-master + - 'snomed-release-*' + - snomed-temp tags: - - '[0-9]+.[0-9]+.[0-9]+' - -env: - HELM_CHART_PATH: package/helm/ + - 'snomed-[0-9]+.[0-9]+.[0-9]+' jobs: - build-publish-docker-helm: - name: Build & Publish Docker Image & Helm Chart + build-publish-docker: + name: Build & Publish Docker Image runs-on: ubuntu-latest services: mysql: @@ -24,11 +22,6 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Set env.ARTIFACT_VERSION - run: | - wget -q https://raw.githubusercontent.com/Bahmni/bahmni-infra-utils/main/setArtifactVersion.sh && chmod +x setArtifactVersion.sh - ./setArtifactVersion.sh - rm setArtifactVersion.sh - name: Setup Java 11 uses: actions/setup-java@v3 with: @@ -53,39 +46,25 @@ jobs: platforms: linux/amd64,linux/arm64 file: package/docker/bahmni-reports/Dockerfile push: true - tags: bahmni/reports:${{env.ARTIFACT_VERSION}},bahmni/reports:latest - - - name: Helm - Update Version and Image Tag - run: | - yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml - yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml + tags: bahmni/reports:snomed-${{ github.run_number }},bahmni/reports:snomed-latest - - name: Helm Lint - run: helm lint $HELM_CHART_PATH - - - name: Helm Package - run: helm package $HELM_CHART_PATH - - - name: Helm - Checkout Charts Repository - uses: actions/checkout@v2 - with: - repository: Bahmni/helm-charts - ref: gh-pages - path: helm-charts - persist-credentials: false - - - name: Helm - Copy chart - run: mkdir -p helm-charts/reports/ && cp reports-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/reports/ - - - name: Helm - reIndex - working-directory: helm-charts/ - run: helm repo index --merge index.yaml --url https://bahmni.github.io/helm-charts/ . - - - name: Helm - Publish Chart - working-directory: helm-charts/ + trigger: + name: Trigger Deployment Workflow to SNOMED Environment + 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: | - git config user.name ${{ secrets.BAHMNI_USERNAME}} - git config user.email ${{ secrets.BAHMNI_EMAIL}} - git add . - git commit -m "Release of reports-${{ env.ARTIFACT_VERSION }}" - git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmni/helm-charts.git' gh-pages + 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 \ No newline at end of file diff --git a/.github/workflows/validate_pr.yml b/.github/workflows/validate_pr.yml index 30a2d997..b8699938 100644 --- a/.github/workflows/validate_pr.yml +++ b/.github/workflows/validate_pr.yml @@ -1,7 +1,7 @@ name: Validate PR on: pull_request: - branches: [ master ] + branches: [ snomed-temp ] jobs: build-package: name: Build Package