Skip to content

Commit

Permalink
fix(ci): updating refs in update-k8s-deployments (#748)
Browse files Browse the repository at this point in the history
Co-authored-by: sa-github-api <138766536+sa-github-api@users.noreply.github.com>
  • Loading branch information
NikolaMilosa and sa-github-api authored Aug 19, 2024
1 parent c6c74dc commit 2a1f3a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
if: ${{ github.ref == 'refs/heads/main' }}
uses: ./.github/workflows/update-k8s-deployments
with:
gitlab_api_token: ${{ secrets.GITLAB_K8S_API_TOKEN }}
github_api_token: ${{ secrets.K8S_API_TOKEN }}

########################################
# Deploy to github pages
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/update-k8s-deployments/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: Update k8s deployments
description: Reusable action for updating k8s deployments

inputs:
gitlab_api_token:
description: 'A GitLab API token with access to the k8s repository'
github_api_token:
description: "A Github API token with access to the k8s repository"
required: true

runs:
using: composite
steps:
- name: "☸️ Update k8s deployments"
id: "update_k8s"
env:
GITLAB_API_TOKEN: ${{ inputs.gitlab_api_token }}
GITHUB_API_TOKEN: ${{ inputs.github_api_token }}
shell: bash
run: |
set -eExou pipefail
Expand All @@ -24,7 +25,7 @@ runs:
cd .git
# checkout branch
git clone --depth 10 --branch "main" "https://gitlab-ci-token:${GITLAB_API_TOKEN}@gitlab.com/dfinity-lab/private/k8s/k8s.git"
git clone --depth 10 --branch "main" "https://${GITHUB_API_TOKEN}@github.com/dfinity-ops/k8s.git"
cd k8s
git config user.email "idx@dfinity.org"
Expand All @@ -49,8 +50,23 @@ runs:
# Push changes and create a new merge request
git commit -m "Updating DRE container images from $DRE_REPO_BRANCH branch"
git push \
-o merge_request.create \
-o merge_request.title="[nomrbot] - Updating DRE container images" \
-o merge_request.description="Updating the DRE container images based on the latest changes in the DRE repository - [here](https://github.com/dfinity/dre/commits/$DRE_REPO_BRANCH)" \
--force --set-upstream origin "${K8S_REPO_BRANCH}" || \
git push --force --set-upstream origin "${K8S_REPO_BRANCH}"
echo "k8s_branch=$K8S_REPO_BRANCH" >> $GITHUB_OUTPUT
echo "dre_branch=$DRE_REPO_BRANCH" >> $GITHUB_OUTPUT
- name: "Create mr on k8s repo"
if: ${{ steps.update_k8s.outputs.k8s_branch != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github_api_token }}
script: |
const result = await github.rest.pulls.create({
title: '[nomrbot] - Updating DRE container images',
owner: 'dfinity-ops',
repo: 'k8s',
head: '${{ steps.update_k8s.outputs.k8s_branch }}',
base: 'main',
body: 'Updating the DRE container images based on the latest changes in the DRE repository - [here](https://github.com/dfinity/dre/commits/${{ steps.update_k8s.outputs.dre_branch }})'
});

0 comments on commit 2a1f3a7

Please sign in to comment.