From fcf2bc782835d424bbae456dc5b16533f7f39ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Tue, 23 Jan 2024 11:13:02 +0100 Subject: [PATCH 1/2] fix(dashboard): Automatically update the internal dashboard k8s deployment --- .github/workflows/bazel.yaml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bazel.yaml b/.github/workflows/bazel.yaml index 83a5563b3..86be89cbc 100644 --- a/.github/workflows/bazel.yaml +++ b/.github/workflows/bazel.yaml @@ -62,6 +62,40 @@ jobs: files: | release/* - name: Push images to GitHub Container Registry - if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/container') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/container') || (github.ref == 'refs/heads/main') }} run: bazel query --noshow_progress 'kind("oci_push", ...)' | xargs -I_target bazel run _target -- --tag ${GITHUB_SHA} + - name: Update k8s deployments + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/container') || (github.ref == 'refs/heads/main') }} + run: | + set -eExou pipefail + + # checkout branch + apk add git + git clone "https://gitlab-ci-token:${GITLAB_API_TOKEN}@gitlab.com/dfinity-lab/private/k8s/k8s.git" + + cd k8s + git config user.email "idx@dfinity.org" + git config user.name "IDX Automation" + git checkout -b "update-image-tag-${GITHUB_SHA}" + + # Update the internal dashboard image refs + # this regex matches the first group (ie the image name) and uses \1 + # called a back-reference to insert the first group matched, the second + # part is to match the 40 characters hash that we replace with the $GITHUB_SHA + sed -i "s~\(\([[:alpha:]]\|-\)\+\):[[:alnum:]]\{40\}~\1:${GITHUB_SHA}~g" bases/apps/mainnet-dashboard/statefulset-slack.yaml bases/apps/mainnet-dashboard/backend/base/deployment.yaml bases/apps/mainnet-dashboard/frontend/deployment.yaml + + # commit changes if there are any + git add . + if git diff --cached --quiet; then + echo "No changes to commit." + exit 0 + fi + + # Push changes and create a new merge request + git commit -m "Updating container base image refs" + git push \ + -o merge_request.create \ + -o merge_request.title="[nomrbot] - Updating container image refs mainnet-dashboard [$GITHUB_SHA]" \ + -o merge_request.description="Changes to the release repository - [here](https://github.com/dfinity/dre/commit/$GITHUB_SHA)" \ + --force --set-upstream origin "update-image-tag-${GITHUB_SHA}" From 2681232c3bc3b4132b8fb6e2d9a548cc76911814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Tue, 23 Jan 2024 12:07:33 +0100 Subject: [PATCH 2/2] Update .github/workflows/bazel.yaml Co-authored-by: Luka Skugor --- .github/workflows/bazel.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/bazel.yaml b/.github/workflows/bazel.yaml index 86be89cbc..a09b8d952 100644 --- a/.github/workflows/bazel.yaml +++ b/.github/workflows/bazel.yaml @@ -71,7 +71,6 @@ jobs: set -eExou pipefail # checkout branch - apk add git git clone "https://gitlab-ci-token:${GITLAB_API_TOKEN}@gitlab.com/dfinity-lab/private/k8s/k8s.git" cd k8s