|
| 1 | +name: Build and Publish |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - 'release-*' |
| 7 | + tags: |
| 8 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 9 | + paths-ignore: |
| 10 | + - "**.md" |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-publish-docker-helm: |
| 14 | + name: Build & Publish Docker Image & Helm Chart |
| 15 | + runs-on: ubuntu-latest |
| 16 | + env: |
| 17 | + HELM_CHART_PATH: package/helm/ |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + - name: Set env.ARTIFACT_VERSION |
| 21 | + run: | |
| 22 | + wget -q https://raw.githubusercontent.com/Bahmni/bahmni-infra-utils/main/setArtifactVersion.sh && chmod +x setArtifactVersion.sh |
| 23 | + ./setArtifactVersion.sh |
| 24 | + rm setArtifactVersion.sh |
| 25 | + - name: Use Node.js 14.x |
| 26 | + uses: actions/setup-node@v1 |
| 27 | + with: |
| 28 | + node-version: 14.x |
| 29 | + - name: Install dependencies ui |
| 30 | + run: cd ui && npm install |
| 31 | + - name: Install dependencies root |
| 32 | + run: npm install |
| 33 | + - name: run test |
| 34 | + run: npm run test |
| 35 | + - name: Build |
| 36 | + run: npm run build |
| 37 | + - name: Login to DockerHub |
| 38 | + uses: docker/login-action@v1 |
| 39 | + with: |
| 40 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 41 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 42 | + - name: Docker Build and push |
| 43 | + uses: docker/build-push-action@v2 |
| 44 | + with: |
| 45 | + context: . |
| 46 | + file: package/docker/Dockerfile |
| 47 | + push: true |
| 48 | + tags: bahmni/appointments:${{env.ARTIFACT_VERSION}},bahmni/appointments:latest |
| 49 | + - name: Helm - Update Version and Image Tag |
| 50 | + run: | |
| 51 | + yq --inplace '.image.tag = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/values.yaml |
| 52 | + yq --inplace '.version = "${{ env.ARTIFACT_VERSION }}"' $HELM_CHART_PATH/Chart.yaml |
| 53 | +
|
| 54 | + - name: Helm Lint |
| 55 | + run: helm lint $HELM_CHART_PATH |
| 56 | + |
| 57 | + - name: Helm Package |
| 58 | + run: helm package $HELM_CHART_PATH |
| 59 | + |
| 60 | + - name: Helm - Checkout Charts Repository |
| 61 | + uses: actions/checkout@v2 |
| 62 | + with: |
| 63 | + repository: Bahmni/helm-charts |
| 64 | + ref: gh-pages |
| 65 | + path: helm-charts |
| 66 | + persist-credentials: false |
| 67 | + |
| 68 | + - name: Helm - Copy chart |
| 69 | + run: mkdir -p helm-charts/appointments/ && cp appointments-${{ env.ARTIFACT_VERSION }}.tgz helm-charts/appointments/ |
| 70 | + |
| 71 | + - name: Helm - reIndex |
| 72 | + working-directory: helm-charts/ |
| 73 | + run: helm repo index --merge index.yaml --url https://bahmni.github.io/helm-charts/ . |
| 74 | + |
| 75 | + - name: Helm - Publish Chart |
| 76 | + working-directory: helm-charts/ |
| 77 | + run: | |
| 78 | + git config user.name ${{ secrets.BAHMNI_USERNAME}} |
| 79 | + git config user.email ${{ secrets.BAHMNI_EMAIL}} |
| 80 | + git add . |
| 81 | + git commit -m "Release of bahmni-web-${{ env.ARTIFACT_VERSION }}" |
| 82 | + git push 'https://${{ secrets.BAHMNI_USERNAME}}:${{ secrets.BAHMNI_PAT}}@github.com/bahmni/helm-charts.git' gh-pages |
0 commit comments