From 1495093905997498a8129d35b60b25cd500585cf Mon Sep 17 00:00:00 2001 From: Milan Dufek Date: Mon, 24 Aug 2026 15:13:02 +0200 Subject: [PATCH] fix(ci): skip the gitops PR when there is nothing to deploy build-helmreleases drops a cluster from its output when the target HelmRelease already matches the built chart ("There is nothing to update for chart lcm-bricks in cluster 62, skipping..."). create-staging-pr and create-manual-merge-prod-pr ran anyway, produced an empty commit ("Working tree clean. Nothing to commit.", committed: false) and then died in gh pr create: pull request create failed: GraphQL: ... No commits between master and gooddata-ruby/091e94de, Head ref must be a branch This is reachable whenever a previous attempt already delivered part of the change. It happened on PR #2092: the 11:00Z attempt created and merged its staging PR (gitops-deployments#26557) before the run stalled on runner availability and the merge queue ejected the PR, so the retry found stg1 already on 2.0.9 and could not open a staging PR at all. Gate the PR-creating steps on the commit actually having been made. A push that fails still fails the step, so committed == 'true' only filters the genuine no-op. Emit a step summary in that case rather than passing silently. Two downstream consumers had to follow, since an empty output is now reachable where it previously was not: - revert-staging-pr would run `git revert --no-commit ""` on an empty commit_hash if e2e failed after a no-op staging step; require a non-empty commit_hash. - create-pr-comment advertised "PR for all clusters -> " with a blank URL; say no delivery is needed instead. Also quote the assignment. JIRA: GRIF-518 --- .../workflows/create-gitops-deployments-pr.yaml | 13 +++++++++++-- .github/workflows/create-pr-comment.yaml | 17 +++++++++++------ .github/workflows/lcm-pipeline.yaml | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-gitops-deployments-pr.yaml b/.github/workflows/create-gitops-deployments-pr.yaml index e4f7cc4be..393c20262 100644 --- a/.github/workflows/create-gitops-deployments-pr.yaml +++ b/.github/workflows/create-gitops-deployments-pr.yaml @@ -175,8 +175,17 @@ jobs: author_email: "infra+yenkins@gooddata.com>" new_branch: "${{ steps.prepare-pr-metadata.outputs.branch_name }}" + - name: Report nothing to deploy + if: ${{ steps.commit-and-push.outputs.committed != 'true' }} + run: | + echo "### :information_source: Nothing to deploy" >> $GITHUB_STEP_SUMMARY + echo "The target HelmReleases already match the built chart and images, so no" >> $GITHUB_STEP_SUMMARY + echo "commit was produced and no gitops-deployments PR was opened." >> $GITHUB_STEP_SUMMARY + echo "Branch that would have been used: \`${{ steps.prepare-pr-metadata.outputs.branch_name }}\`" >> $GITHUB_STEP_SUMMARY + - name: Create PR id: create-pr + if: ${{ steps.commit-and-push.outputs.committed == 'true' }} run: | pr_url=$(gh pr create \ --title "${{ steps.prepare-pr-metadata.outputs.pr_title }}" \ @@ -195,14 +204,14 @@ jobs: GH_TOKEN: ${{ secrets.TOKEN_GITHUB_YENKINS }} - name: Upload PR URL - if: ${{ inputs.is_staging == false && inputs.is_auto_merge == true }} + if: ${{ steps.commit-and-push.outputs.committed == 'true' && inputs.is_staging == false && inputs.is_auto_merge == true }} uses: actions/upload-artifact@v4 with: name: "${{ inputs.cluster }}_pr_url" path: "${{ inputs.cluster }}_pr_url.txt" - name: Approve the PR - if: ${{ inputs.is_staging == true }} + if: ${{ steps.commit-and-push.outputs.committed == 'true' && inputs.is_staging == true }} run: gh pr review --approve env: GH_TOKEN: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN}} diff --git a/.github/workflows/create-pr-comment.yaml b/.github/workflows/create-pr-comment.yaml index ee74af51f..dff38067a 100644 --- a/.github/workflows/create-pr-comment.yaml +++ b/.github/workflows/create-pr-comment.yaml @@ -76,14 +76,19 @@ jobs: cat "$comment_file" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else - pr_url=${{ inputs.deployment_pr_url }} + pr_url="${{ inputs.deployment_pr_url }}" - pr_comment=":exclamation: **THIS PULL REQUEST WILL NEED TO BE DELIVERED MANUALLY** :exclamation: - :exclamation: *REVERT following gitops-deployments PR bellow to rollback this change* :exclamation: - * PR for **all clusters** :arrow_right:: ${pr_url} + if [[ -z "$pr_url" ]]; then + pr_comment=":information_source: **NO PRODUCTION DELIVERY NEEDED** + The production HelmReleases already match the built chart and images, so no gitops-deployments PR was opened." + else + pr_comment=":exclamation: **THIS PULL REQUEST WILL NEED TO BE DELIVERED MANUALLY** :exclamation: + :exclamation: *REVERT following gitops-deployments PR bellow to rollback this change* :exclamation: + * PR for **all clusters** :arrow_right:: ${pr_url} - :warning: Pushing another change before rolling out this change might cause confliction in [gitops-deployments](https://github.com/gooddata/gitops-deployments) repo - :point_right: Merging progress will be informed in [#cd-pipelines-release-prod](https://app.slack.com/client/T02G0PHRH/C0504DF292T) slack channel" + :warning: Pushing another change before rolling out this change might cause confliction in [gitops-deployments](https://github.com/gooddata/gitops-deployments) repo + :point_right: Merging progress will be informed in [#cd-pipelines-release-prod](https://app.slack.com/client/T02G0PHRH/C0504DF292T) slack channel" + fi echo "pr_comment<> $GITHUB_OUTPUT echo "$pr_comment" >> $GITHUB_OUTPUT diff --git a/.github/workflows/lcm-pipeline.yaml b/.github/workflows/lcm-pipeline.yaml index f52f19c83..9ca42eec7 100644 --- a/.github/workflows/lcm-pipeline.yaml +++ b/.github/workflows/lcm-pipeline.yaml @@ -259,6 +259,7 @@ jobs: needs.wait-for-deployment.result == 'failure' || needs.lcm-integration-e2e.result == 'failure' ) && + needs.create-staging-pr.outputs.commit_hash != '' && inputs.deploy uses: ./.github/workflows/revert-staging-pr.yaml with: