diff --git a/.github/workflows/update-k8s-deployments/action.yaml b/.github/workflows/update-k8s-deployments/action.yaml index e8b46a4..19eac6b 100644 --- a/.github/workflows/update-k8s-deployments/action.yaml +++ b/.github/workflows/update-k8s-deployments/action.yaml @@ -69,12 +69,30 @@ runs: with: github-token: ${{ inputs.push-token }} script: | - 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 }}).' + const owner = 'dfinity-ops'; + const repo = 'k8s'; + const base = 'main'; + const pulls = await github.rest.pulls.list({ + 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: 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: owner, + repo: repo, + head: '${{ steps.create-rollout-commit.outputs.k8s_branch }}', + 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 }}).' + }); + }