From 39c0fc6d984d7f65bdba04aa0a5bfeec99e6fe21 Mon Sep 17 00:00:00 2001 From: Manuel Amador Date: Thu, 23 Jan 2025 16:23:05 +0100 Subject: [PATCH 1/2] Update pull request descrcription if exists. --- .../update-k8s-deployments/action.yaml | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-k8s-deployments/action.yaml b/.github/workflows/update-k8s-deployments/action.yaml index e8b46a4..c136463 100644 --- a/.github/workflows/update-k8s-deployments/action.yaml +++ b/.github/workflows/update-k8s-deployments/action.yaml @@ -69,12 +69,27 @@ runs: with: github-token: ${{ inputs.push-token }} script: | - const result = await github.rest.pulls.create({ - title: '[nomrbot] - New ${{ inputs.component }} release from ${{ github.repository }}', + const pulls = await github.rest.pulls.list({ owner: 'dfinity-ops', repo: 'k8s', - head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}', base: 'main', - maintainer_can_modify: true, - body: 'Updating container images to incorporate [these changes](https://github.com/${{ github.repository }}/compare/${{ steps.create-rollout-commit.outputs.previous_ref }}..${{ steps.create-rollout-commit.outputs.current_ref }}).' + head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}' }); + if (pulls.length > 0) { + const result = await github.rest.pulls.update({ + owner: 'dfinity-ops', + repo: 'k8s', + pull_number: pulls[0]["number"], + body: 'Updating container images to incorporate [these changes](https://github.com/${{ github.repository }}/compare/${{ steps.create-rollout-commit.outputs.previous_ref }}..${{ steps.create-rollout-commit.outputs.current_ref }}).', + }); + } else { + const result = await github.rest.pulls.create({ + title: '[nomrbot] - New ${{ inputs.component }} release from ${{ github.repository }}', + owner: 'dfinity-ops', + repo: 'k8s', + head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}', + base: 'main', + maintainer_can_modify: true, + body: 'Updating container images to incorporate [these changes](https://github.com/${{ github.repository }}/compare/${{ steps.create-rollout-commit.outputs.previous_ref }}..${{ steps.create-rollout-commit.outputs.current_ref }}).' + }); + } From cc723a8062123aaf55888f45e0648b17fd66c25d Mon Sep 17 00:00:00 2001 From: Manuel Amador Date: Thu, 23 Jan 2025 16:24:37 +0100 Subject: [PATCH 2/2] Constify. --- .../update-k8s-deployments/action.yaml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-k8s-deployments/action.yaml b/.github/workflows/update-k8s-deployments/action.yaml index c136463..19eac6b 100644 --- a/.github/workflows/update-k8s-deployments/action.yaml +++ b/.github/workflows/update-k8s-deployments/action.yaml @@ -69,26 +69,29 @@ runs: with: github-token: ${{ inputs.push-token }} script: | + const owner = 'dfinity-ops'; + const repo = 'k8s'; + const base = 'main'; const pulls = await github.rest.pulls.list({ - owner: 'dfinity-ops', - repo: 'k8s', - base: 'main', + owner: owner, + repo: repo, + base: base, head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}' }); if (pulls.length > 0) { const result = await github.rest.pulls.update({ - owner: 'dfinity-ops', - repo: 'k8s', + owner: owner, + repo: repo, pull_number: pulls[0]["number"], body: 'Updating container images to incorporate [these changes](https://github.com/${{ github.repository }}/compare/${{ steps.create-rollout-commit.outputs.previous_ref }}..${{ steps.create-rollout-commit.outputs.current_ref }}).', }); } else { const result = await github.rest.pulls.create({ title: '[nomrbot] - New ${{ inputs.component }} release from ${{ github.repository }}', - owner: 'dfinity-ops', - repo: 'k8s', + owner: owner, + repo: repo, head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}', - base: 'main', + base: base, maintainer_can_modify: true, body: 'Updating container images to incorporate [these changes](https://github.com/${{ github.repository }}/compare/${{ steps.create-rollout-commit.outputs.previous_ref }}..${{ steps.create-rollout-commit.outputs.current_ref }}).' });