diff --git a/.github/workflows/cd-web.yaml b/.github/workflows/cd-web.yaml index daef99a7..9f858126 100644 --- a/.github/workflows/cd-web.yaml +++ b/.github/workflows/cd-web.yaml @@ -58,38 +58,38 @@ jobs: # image_tag: ${{ env.IMAGE_TAG_PREFIX }}-${{ steps.short_sha.outputs.SHORT_SHA }} # helm_property: /webtag # helm_paths: web/values.yaml ../develop/values.yaml - - - name: Checkout ArgoCD Repo - id: gitops - uses: actions/checkout@v4 - with: - repository: bcgov-c/tenant-gitops-${{ inputs.licence_plate }} - ref: ${{ inputs.gitops_branch }} - token: ${{ inputs.gitops_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' - shell: bash - run: | - # Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and - cd gitops/charts + - name: Checkout ArgoCD Repo + id: gitops + uses: actions/checkout@v4 + with: + repository: bcgov-c/tenant-gitops-${{ inputs.licence_plate }} + ref: ${{ inputs.gitops_branch }} + token: ${{ inputs.gitops_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' + shell: bash + run: | + # 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 + # 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 - # Split incoming helm_paths by space into an array and loop through each path update the image tag in each file - IFS=' ' read -r -a paths <<< "${{ inputs.helm_paths }}" - for path in "${paths[@]}"; do - sed -i "s/${{ inputs.helm_property }}: .*/${{ inputs.helm_property }}: ${{ inputs.image_tag }} # Image Updated on $DATETIME/" $path - # Stage the changed path immediately for upcoming commit - git add $path - done + # Split incoming helm_paths by space into an array and loop through each path update the image tag in each file + IFS=' ' read -r -a paths <<< "${{ inputs.helm_paths }}" + for path in "${paths[@]}"; do + sed -i "s/${{ inputs.helm_property }}: .*/${{ inputs.helm_property }}: ${{ inputs.image_tag }} # Image Updated on $DATETIME/" $path + # Stage the changed path immediately for upcoming commit + git add $path + done - # Commit and push the changes - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" + # Commit and push the changes + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" - git commit -m "Update API image tag" - git push origin ${{ inputs.gitops_branch }} + git commit -m "Update API image tag" + git push origin ${{ inputs.gitops_branch }}