shell-plugins icon indicating copy to clipboard operation
shell-plugins copied to clipboard

fix(ci): Update existing flake.lock PR if it exists already

Open mrjones2014 opened this issue 9 months ago • 0 comments

Overview

If a flake.lock automated PR already exists and hasn't been merged by the time a new job runs to create a new PR, it updates the existing PR instead of trying to create a new PR and failing because the branch already exists.

Type of change

  • [ ] Created a new plugin
  • [ ] Improved an existing plugin
  • [ ] Fixed a bug in an existing plugin
  • [x] Improved contributor utilities or experience

Related Issue(s)

  • Resolves: #467

How To Test

Read the changed bash script and ensure it makes sense. You can also test out the logic locally on a test repo. The thinking in the first few lines (the first if block) is:

  • If the branch already exists on remote, checkout and pull before trying to update flake.lock (this is to ensure we can push new changes, e.g. a commit exists on remote that we don't have locally)
  • Otherwise, create the branch and push the empty branch to remote
  • Then run nix flake update, which now runs on the latest version of the file from the branch
  • Push the changes to the branch
    • If the branch already existed and had a PR for it, pushing new commits to the branch will update the existing PR

Changelog

Update flake.lock CI automation to update existing PR if there is one.

mrjones2014 avatar May 24 '24 13:05 mrjones2014