From 9250afeab7d590f0997756b09fc8972687f35319 Mon Sep 17 00:00:00 2001 From: JonTaylorBCGov2 <55515424+JonTaylorBCGov2@users.noreply.github.com> Date: Tue, 28 May 2024 13:35:12 -0700 Subject: [PATCH] Update web-buildandpush.yaml --- .github/workflows/web-buildandpush.yaml | 71 +++++++++++++++---------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/.github/workflows/web-buildandpush.yaml b/.github/workflows/web-buildandpush.yaml index df16ecf7..2fc5176b 100644 --- a/.github/workflows/web-buildandpush.yaml +++ b/.github/workflows/web-buildandpush.yaml @@ -31,39 +31,52 @@ jobs: - run: npm run build --if-present working-directory: ${{env.working-directory}} - # # Get SHORT_SHA to tag images - # - name: Get short SHA - # id: short_sha - # run: | - # echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)" - # echo "Short SHA: $SHORT_SHA" - - # - name: Install dependencies - # run: dotnet restore - # working-directory: ${{env.WORKING_DIRECTORY}} - - # - name: Build - # run: dotnet build --configuration Release --no-restore - # working-directory: ${{env.WORKING_DIRECTORY}} - - # - name: Test - # run: dotnet test --no-restore --verbosity normal - # working-directory: ${{env.WORKING_DIRECTORY}} - - # - name: Push to Artifactory - # id: publish - # run: dotnet push artifacts.developer.gov.bc.ca/cac1-cas-api/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }} + # Get SHORT_SHA to tag images + - name: Get short SHA + id: short_sha + run: | + echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)" + echo "Short SHA: $SHORT_SHA" - # - name: Docker Build Backend Image - # working-directory: ${{env.WORKING_DIRECTORY}}web/ - # run: | - # docker build --tag web . - # docker tag web artifacts.developer.gov.bc.ca/cac1-cas/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }} - # # docker compose build backend - # # docker tag cas-web artifacts.developer.gov.bc.ca/cac1-cas-web/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }} + - name: Docker Build Web Image + working-directory: ${{env.WORKING_DIRECTORY}}web/ + run: | + docker build --tag web . --file web/Dockerfile + docker tag web artifacts.developer.gov.bc.ca/cac1-cas/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }} - name: Docker Push to Artifactory id: publish run: | docker push artifacts.developer.gov.bc.ca/cac1-cas/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }} + - name: Checkout ArgoCD Repo + id: gitops + uses: actions/checkout@v4 + with: + repository: bcgov-c/tenant-gitops-ac1cc8 + ref: develop + token: ${{ secrets.GIT_OPS_SSH_KEY }} # `GH_PAT` is a secret that contains your PAT + path: gitops + + - name: Update Helm Values and Commit + id: helm + if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful + run: | + # Clone the GitOps deployment configuration repository + # Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and + cd gitops/charts + + # Update the Helm values file with the new image tag and version + DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time + + sed -i "s/apitag: .*/apitag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/dev_values.yaml + + sed -i "s/apitag: .*/apitag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" web/values.yaml + + # Commit and push the changes + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + + git add . + + git add ../deploy/dev_values.yaml