diff --git a/.github/actions/argocd-update/action.yml b/.github/actions/argocd-update/action.yml new file mode 100644 index 0000000..88c0c72 --- /dev/null +++ b/.github/actions/argocd-update/action.yml @@ -0,0 +1,75 @@ +name: "Argo CD update" +description: "Push changes to a branch in ArgoCD" +inputs: + repository: + description: "The ArgoCD repository" + required: true + ssh_key: + description: "The SSH key for the repository" + required: true + branch: + description: "The branch to update" + required: true + version: + description: "The version to use for updating" + required: true + subdirectory: + description: "The subdirectory to update" + required: true + clone_into: + description: "The directory to clone the argocd repo into" + default: "argocd-repo" + required: false +outputs: {} +runs: + using: "composite" + steps: + - name: Check out the repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository }} + ssh-key: ${{ inputs.ssh_key }} + path: ${{ inputs.clone_into }} + - name: Git commit and push to remote + shell: bash + run: | + set -xe + cd ${{ inputs.clone_into }} + git config --global user.name "coredb-service-user" + git config --global user.email "admin+github@coredb.io" + git fetch origin ${{ inputs.branch }} && git checkout ${{ inputs.branch }} || git checkout -b ${{ inputs.branch }} + + - name: Update for dev or staging deployments + if: inputs.branch == 'staging-updates' || (inputs.branch == 'main' && inputs.subdirectory == 'dev') + uses: mikefarah/yq@v4.44.2 + with: + cmd: | + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-use1.yaml + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-euc1.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-use1.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-euc1.yaml + + - name: Update for prod deployments + if: inputs.branch == 'prod-updates' + uses: mikefarah/yq@v4.44.2 + with: + cmd: | + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-use1.yaml + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-euc1.yaml + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-apse1.yaml + yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-usw2.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-use1.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-euc1.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-apse1.yaml + yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/tembo-metrics-usw2.yaml + + - name: Git commit and push to remote + shell: bash + run: | + set -xe + cd ${{ inputs.clone_into }} + git add --all + # debugging + git diff HEAD + git commit -m "Update from coredb-io/control-plane: ${{ inputs.version }}" + git push origin ${{ inputs.branch }} diff --git a/.github/workflows/build-push.yaml b/.github/workflows/build-push.yaml index 5780ae7..7702454 100644 --- a/.github/workflows/build-push.yaml +++ b/.github/workflows/build-push.yaml @@ -57,7 +57,6 @@ jobs: if: ${{ github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest strategy: - # fail-fast means to cancel all jobs if one fails fail-fast: false matrix: include: