Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgoCD update automation #231

Merged
merged 7 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/actions/argocd-update/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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 checkout ${{ inputs.branch }} || git checkout -b ${{ inputs.branch }}
- name: Update trunk registry
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/pgtrunkio-backend.yaml
- name: Update coredb operator helm chart
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '.spec.source.targetRevision= "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/coredb-operator.yaml
- name: Update coredb operator image
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ inputs.version }}"' ${{ inputs.clone_into }}/${{ inputs.subdirectory }}/coredb-operator.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/coredb: ${{ inputs.version }}"
git push origin ${{ inputs.branch }}
49 changes: 23 additions & 26 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,35 @@ jobs:
quay_user: ${{ secrets.QUAY_USER }}
quay_password: ${{ secrets.QUAY_PASSWORD }}

update_argocd_dev:
name: Update ArgoCD in dev environment
argocd_update:
name: ArgoCD update automation
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-20.04
strategy:
# fail-fast means to cancel all jobs if one fails
fail-fast: false
matrix:
include:
- repository: coredb-io/app-deploy-dev
subdirectory: dev
branch: main
- repository: coredb-io/app-deploy
subdirectory: staging
branch: staging-updates
- repository: coredb-io/app-deploy
subdirectory: prod
branch: prod-updates
needs:
- find_directories
- build_and_push_images
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Check out the repo
uses: ./.github/actions/argocd-update
with:
repository: coredb-io/app-deploy-dev
ssh-key: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }}
- name: Update trunk registry
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ needs.find_directories.outputs.short_sha }}"' dev/pgtrunkio-backend.yaml
- name: Update coredb operator helm chart
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '.spec.source.targetRevision= "${{ needs.find_directories.outputs.short_sha }}"' dev/coredb-operator.yaml
- name: Update coredb operator image
uses: mikefarah/yq@v4.33.3
with:
cmd: yq -i '(.spec.source.helm.parameters.[] | select(.name == "image.tag")).value = "${{ needs.find_directories.outputs.short_sha }}"' dev/coredb-operator.yaml
- name: Git commit and push to remote
run: |
set -xe
git config --global user.name "coredb-service-user"
git config --global user.email "admin+github@coredb.io"
git add --all
# debugging
git diff HEAD
git commit -m "Update from coredb-io/coredb: ${{ needs.find_directories.outputs.short_sha }}"
git push origin main
repository: ${{ matrix.repository }}
ssh_key: ${{ secrets.SERVICE_USER_GITHUB_SSH_KEY }}
branch: ${{ matrix.branch }}
version: ${{ needs.find_directories.outputs.short_sha }}
subdirectory: ${{ matrix.subdirectory }}
1 change: 1 addition & 0 deletions coredb-operator/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CoreDB Operator


A Rust-based Kubernetes Controller for a [`CoreDB Resource`](https://github.com/CoreDB-io/coredb/blob/main/coredb-operator/charts/coredb-operator/templates/crd.yaml) using [kube-rs](https://github.com/kube-rs/kube-rs/).

The `Controller` object reconciles `CoreDB` Instances when changes to it are detected, writes to its .status object, creates associated events, and uses finalizers for guaranteed delete handling.
Expand Down