Release dbadapter/1 1 0 #7
This file contains hidden or 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: PayQueryService-Build & Deploy to Prod | |
| on: | |
| pull_request: | |
| types: [opened, reopened,edited,synchronize] | |
| branches: | |
| - 'main' | |
| paths: | |
| - rsbc-ride-payment-query-svc/** | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.event.pull_request.head.ref, 'release-payquery/') | |
| # if: ${{ !( | |
| # github.event.pull_request.head.ref =~ '^hotfixrelease/' || | |
| # github.event.pull_request.head.ref =~ '^hotfix/' || | |
| # github.event.pull_request.head.ref =~ '^dependabot/'|| | |
| # github.event.pull_request.head.ref =~ '^feature/' | |
| # )}} | |
| # if: ${{ github.event.pull_request.head.ref =~ '^release/' }} | |
| # if: startsWith(github.event.pull_request.head.ref, 'release/') | |
| env: | |
| DOCKER_IMAGE_TAG: ${{ github.sha}} | |
| DOCKER_CONTEXT_FOLDER: rsbc-ride-payment-query-svc | |
| DOCKER_IMAGE_NAME: rbe5-images/rsbc-ride-payment-query-svc-prod | |
| DOCKER_FILE: rsbc-ride-payment-query-svc/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/[email protected] | |
| 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: ${{ env.DOCKER_CONTEXT_FOLDER }} | |
| 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_prod_argocd: | |
| name: Push to Gitops repo for prod deployment via Argocd | |
| runs-on: ubuntu-latest | |
| 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/paymentservice | |
| token: ${{ secrets.GITOPS_GITHUB_TOKEN }} | |
| # - name: New PR Branch | |
| # run: | | |
| # git config user.name github-actions | |
| # git config user.email [email protected] | |
| # 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/[email protected] | |
| with: | |
| cmd: yq eval -i '.images[0].newTag = "${{env.PR_IMAGE_STREAM_TAG}}"' 'overlays/prod/kustomization.yaml' | |
| # - name: Update name suffix for Dev deploy | |
| # uses: mikefarah/[email protected] | |
| # with: | |
| # cmd: yq eval -i '.nameSuffix = "-dev"' 'overlays/dev/kustomization.yaml' | |
| # - name: Update app name label for Dev deploy | |
| # uses: mikefarah/[email protected] | |
| # 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/[email protected] | |
| # 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/[email protected] | |
| with: | |
| cmd: yq eval -i '.commonAnnotations.release_name = "${{env.RELEASE_NAME}}"' 'overlays/prod/kustomization.yaml' | |
| # - name: Update hpa Dev name | |
| # uses: mikefarah/[email protected] | |
| # 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/[email protected] | |
| with: | |
| cmd: yq eval -i '.commonAnnotations.commit_sha = "${{env.PR_IMAGE_STREAM_TAG}}"' 'overlays/prod/kustomization.yaml' | |
| - name: Check Changed value | |
| run: | | |
| cat overlays/prod/kustomization.yaml | |
| - name: Push Changes | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| git add . | |
| git commit -m "updated prod deploy details to prod overlay yaml" | |
| git push -u origin deployment/paymentservice |