diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 490b1f378..d6d8fedfe 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -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 diff --git a/.github/workflows/update-k8s-deployments/action.yaml b/.github/workflows/update-k8s-deployments/action.yaml index 75849c9f8..d5c1302e7 100644 --- a/.github/workflows/update-k8s-deployments/action.yaml +++ b/.github/workflows/update-k8s-deployments/action.yaml @@ -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 @@ -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" @@ -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 }})' + });