Skip to content

Treat errors on repeated runs gracefully #470

Closed

Description

@wolfgangwalther

Describe the bug

When the action is run multiple times, it generates comments with error messages, even though all is good.

To Reproduce
Steps to reproduce the behavior:

  1. Set up the action to trigger on an already merged PR's label event.
  2. Add two backport labels at the same time (this results in two label events from GitHub :/)
  3. See the action running two times and posting unhelpful comments.

Alternative: Add labels one at a time. Running the action the second time, will try to create the first PR again - throwing the same errors.

Expected behavior

The backport action should just detect already existing branches and PRs, ignore them and keep going.

Workflow run logs

Workflow run logs

 Retrieve pull request data for #412688
Check whether pull request 412688 is merged
Determining target branches...
Detected labels on PR: 8.has: port to stable,10.rebuild-darwin: 0,10.rebuild-linux: 0,backport release-24.11,backport release-25.05
label '8.has: port to stable' doesn't match `label_pattern` '^backport ([^ ]+)$'
label '10.rebuild-darwin: 0' doesn't match `label_pattern` '^backport ([^ ]+)$'
label '10.rebuild-linux: 0' doesn't match `label_pattern` '^backport ([^ ]+)$'
Found target branches in labels: release-24.11,release-25.05
Found target branches in `target_branches` input: 
Exclude pull request's headref from target branches: ci-workflow-ci-owners
Determined target branches: release-24.11,release-25.05
Fetching all the commits from the pull request: 2
git fetch --depth=2 origin refs/pull/412688/head
From https://github.com/NixOS/nixpkgs
 * branch                refs/pull/412688/head -> FETCH_HEAD
Retrieving the commits from pull request 412688
PR was merged using a merge commit
Found commits to backport: b98e7bb95a1e66d951a9c517cadb151694358bad
Checking the merged pull request for merge commits
git rev-list --merges b98e7bb95a1e66d951a9c517cadb151694358bad^..b98e7bb95a1e66d951a9c517cadb151694358bad
Encountered 0 merge commits
Will cherry-pick the following commits: b98e7bb95a1e66d951a9c517cadb151694358bad
Will copy labels matching /severity:\ssecurity/. Found matching labels: 
Backporting to target branch 'release-24.11...'
git fetch --depth=1 origin release-24.11
From https://github.com/NixOS/nixpkgs
 * branch                release-24.11 -> FETCH_HEAD
 * [new branch]          release-24.11 -> origin/release-24.11
Start backport to backport-412688-to-release-24.11
git switch -c backport-412688-to-release-24.11 origin/release-24.11
Warning: you are leaving 2 commits behind, not connected to
any of your branches:

  b98e7bb95 OWNERS: simplify workflow/ci owners
  9137f06a0 Xfce updates 2025-05-28 (#411782)

If you want to keep them by creating a new branch, this may be a good time
to do so with:

 git branch <new-branch-name> b98e7bb95

Switched to a new branch 'backport-412688-to-release-24.11'
git cherry-pick -x b98e7bb95a1e66d951a9c517cadb151694358bad
error: could not apply b98e7bb95... OWNERS: simplify workflow/ci owners
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
git cherry-pick --abort
Backport failed for `release-24.11`, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.
``bash
git fetch origin release-24.11
git worktree add -d .worktree/backport-412688-to-release-24.11 origin/release-24.11
cd .worktree/backport-412688-to-release-24.11
git switch --create backport-412688-to-release-24.11
git cherry-pick -x b98e7bb95a1e66d951a9c517cadb151694358bad
``
Create comment: Backport failed for `release-24.11`, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.
``bash
git fetch origin release-24.11
git worktree add -d .worktree/backport-412688-to-release-24.11 origin/release-24.11
cd .worktree/backport-412688-to-release-24.11
git switch --create backport-412688-to-release-24.11
git cherry-pick -x b98e7bb95a1e66d951a9c517cadb151694358bad
``
Backporting to target branch 'release-25.05...'
git fetch --depth=1 origin release-25.05
From https://github.com/NixOS/nixpkgs
 * branch                release-25.05 -> FETCH_HEAD
 * [new branch]          release-25.05 -> origin/release-25.05
Start backport to backport-412688-to-release-25.05
git switch -c backport-412688-to-release-25.05 origin/release-25.05
Switched to a new branch 'backport-412688-to-release-25.05'
git cherry-pick -x b98e7bb95a1e66d951a9c517cadb151694358bad
Push branch to origin
git push --set-upstream origin backport-412688-to-release-25.05
To https://github.com/NixOS/nixpkgs
 ! [rejected]            backport-412688-to-release-25.05 -> backport-412688-to-release-25.05 (fetch first)
Create comment: Git push to origin failed for release-25.05 with exitcode 1
error: failed to push some refs to 'https://github.com/NixOS/nixpkgs'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Git push to origin failed for release-25.05 with exitcode 1

Additional context

PR here: NixOS/nixpkgs#412688

Run: https://github.com/NixOS/nixpkgs/actions/runs/15632399147/job/44039593300

Activity

  1. korthout commented on Jun 21, 2025

    @korthout
    Owner

    Totally agree. Thanks for raising it @wolfgangwalther

    Happy to review a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions