Added Form Statistics to Prometheus monitoring #4
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 & Deploy the service | |
on: | |
pull_request: | |
types: [opened, reopened,edited,synchronize] | |
branches: | |
- 'main' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: startsWith(github.event.pull_request.head.ref, 'release/') | |
environment: prod | |
env: | |
DOCKER_IMAGE_TAG: ${{ github.sha}} | |
DOCKER_IMAGE_NAME: rbe5-images/ride-monitoring-service | |
DOCKER_FILE: Dockerfile | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup | |
uses: docker/setup-buildx-action@v2 | |
with: | |
install: true | |
- name: Login | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Tag | |
id: tag | |
uses: mathieudutour/github-tag-action@v6.1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag_prefix: ${{ env.DOCKER_IMAGE_NAME }}=v | |
fetch_all_tags: true | |
- name: Build | |
uses: docker/build-push-action@v3 | |
with: | |
context: ride-monitoring-svc | |
file: ${{ env.DOCKER_FILE }} | |
push: true | |
build-args: | | |
VERSION=${{ steps.tag.outputs.new_version }} | |
tags: ${{ secrets.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }} | |
deploy_argocd: | |
name: Push to Gitops repo for prod deployment via Argocd | |
runs-on: ubuntu-latest | |
environment: prod | |
needs: [build] | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
PR_IMAGE_STREAM_TAG: ${{ github.sha}} | |
RELEASE_NAME: release_1_0 | |
steps: | |
- name: Checkout Gitops repository | |
uses: actions/checkout@v3 | |
with: | |
repository: bcgov-c/tenant-gitops-be5301 | |
ref: deployment/monitoring-svc | |
token: ${{ secrets.GITOPS_GITHUB_TOKEN }} | |
# - name: New PR Branch | |
# run: | | |
# git config user.name github-actions | |
# git config user.email github-actions@github.com | |
# git pull | |
# git checkout -b pr-branch-${{env.PR_NUMBER}} | |
# git push -u origin pr-branch-${{env.PR_NUMBER}} | |
- name: Update Image tag for prod deploy | |
uses: mikefarah/yq@v4.28.1 | |
with: | |
cmd: yq eval -i '.images[0].newTag = "${{env.PR_IMAGE_STREAM_TAG}}"' 'overlays/tools/kustomization.yaml' | |
# - name: Update name suffix for Dev deploy | |
# uses: mikefarah/yq@v4.28.1 | |
# with: | |
# cmd: yq eval -i '.nameSuffix = "-dev"' 'overlays/dev/kustomization.yaml' | |
# - name: Update app name label for Dev deploy | |
# uses: mikefarah/yq@v4.28.1 | |
# with: | |
# cmd: yq eval -i '.commonLabels["app.kubernetes.io/name"] = "ride-producer-api-dev"' 'overlays/pr/kustomization.yaml' | |
# - name: Update app label for PR deploy | |
# uses: mikefarah/yq@v4.28.1 | |
# with: | |
# cmd: yq eval -i '.commonLabels.app = "ride-producer-api-pr-${{env.PR_NUMBER}}"' 'overlays/pr/kustomization.yaml' | |
- name: Update release name for prod deploy | |
uses: mikefarah/yq@v4.28.1 | |
with: | |
cmd: yq eval -i '.commonAnnotations.release_name = "${{env.RELEASE_NAME}}"' 'overlays/tools/kustomization.yaml' | |
# - name: Update hpa Dev name | |
# uses: mikefarah/yq@v4.28.1 | |
# with: | |
# cmd: yq eval -i '.spec.scaleTargetRef.name = "ride-producer-api-pr-${{env.PR_NUMBER}}"' 'overlays/pr/custom-hpa-ride-producer-api.yml' | |
- name: Update sha annotation | |
uses: mikefarah/yq@v4.28.1 | |
with: | |
cmd: yq eval -i '.commonAnnotations.commit_sha = "${{env.PR_IMAGE_STREAM_TAG}}"' 'overlays/tools/kustomization.yaml' | |
- name: Check Changed value | |
run: | | |
cat overlays/tools/kustomization.yaml | |
- name: Push Changes | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git add . | |
git commit -m "updated prod deploy details to prod overlay yaml" | |
git push -u origin deployment/monitoring-svc | |