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

ci: fixing ci reusable workflows #118

Merged
merged 18 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
########################################
- name: Update k8s deployments
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/container') || (github.ref == 'refs/heads/main') }}
uses: ./.github/workflows/update-k8s-deployments.yml
uses: ./.github/workflows/update-k8s-deployments

########################################
# Optimize bazel cache by hard-linking duplicate files
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
update:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/setup-bazel

########################################
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/update-k8s-deployments.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/update-k8s-deployments/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update k8s deployments
description: Reusable action for updating k8s deployments

runs:
using: composite
steps:
- env:
GITLAB_API_TOKEN: ${{ secrets.GITLAB_API_TOKEN }}
shell: bash
run: |
set -eExou pipefail

cd .git

# checkout branch
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}"
Loading