From aec4ddeed0b1b3ff5a8b05956dd8ae88e18b9c59 Mon Sep 17 00:00:00 2001 From: bobjwalker Date: Tue, 13 Feb 2024 08:17:33 -0600 Subject: [PATCH] Leveraging more conditionals --- .github/workflows/build.yml | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74851cd..26bf9c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,28 +57,18 @@ jobs: - name: update dev kustomize overlay uses: mikefarah/yq@master with: - cmd: yq -i '.images.[0].newTag = "${{ steps.determine_version.outputs.semVer }}"' 'k8s/overlays/${{ github.ref == 'refs/heads/main' && 'dev' || 'test' }}/kustomization.yaml' - - id: commit_dev_kustomize_change - name: commit the dev kustomize change + cmd: yq -i '.images.[0].newTag = "${{ steps.determine_version.outputs.semVer }}"' 'k8s/overlays/${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }}/kustomization.yaml' + - id: commit_kustomize_change + name: commit kustomize change run : | git config --global user.name '${{ github.actor }}' git config --global user.email '${{ github.actor }}@users.noreply.github.com' git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY git checkout "${GITHUB_REF:11}" - git stage 'k8s/overlays/dev/kustomization.yaml' - git commit -am "Updating dev overlay file to ${{ steps.determine_version.outputs.semVer }}" - git tag 'dev-argo' --force + git stage 'k8s/overlays/${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }}/kustomization.yaml' + git commit -am "Updating ${{ github.ref == 'refs/heads/main' && 'test' || 'dev' }} overlay file to ${{ steps.determine_version.outputs.semVer }}" git push --set-upstream origin ${GITHUB_REF:11} - git push origin 'dev-argo' --force - if: contains(github.ref, 'feature') - - id: commit_test_kustomize_change - name: commit the test kustomize change - run : | - git config --global user.name '${{ github.actor }}' - git config --global user.email '${{ github.actor }}@users.noreply.github.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout "${GITHUB_REF:11}" - git stage 'k8s/overlays/test/kustomization.yaml' - git commit -am "Updating test overlay file to ${{ steps.determine_version.outputs.semVer }}" - git push --set-upstream origin ${GITHUB_REF:11} - if: github.ref == 'refs/heads/main' \ No newline at end of file + if "${{ github.ref }}" != "refs/head/main" + git tag 'dev-argo' --force + git push origin 'dev-argo' --force + fi \ No newline at end of file