This is unlikely to be seen outside of my testing. ![]() If the PR already exists with the exact same name, we just move on. ![]() If the repo is archived (set to read-only), there’s nothing we can or should do, so we continue which is bash-speak means skip to the next iteration of the loop. Therefore, you’ll see these || true scattered through my code, which means, or exit 0 if the first command didn’t, and permits me to read errors and attempt recovery, rather than exiting right away. Interestingly, GitHub Actions exits at the first non-0 exit code (runs bash scripts with -e set by default), which is a brittle way to run a service. Note that we’re doing an || true to catch any non-0 exit code. It might not be - we catch the results in the same way, and if we get any issues, we address them as well as we can. Then we do another push, and see if the error is resolved. Even though actions/checkout cloned the files and git metadata down, it doesn’t attach to a branch, but we’ll require that for our git commands below. Then we do what I talked about above - we need to checkout the master branch (that’s the only place our script runs). It’s probably not required here, but I set it on most scripts because it’s bitten me before. This tells bash to read a newline as a separator, a good practice for reading data. We start with setting the IFS, or in bash lingo, how to tell how to separate two strings as individual entries. Bash Scripting with GitHub CLI, Git Set it Up We’re still not attached to a branch, but we can fix that below in our bash script. So the first thing we do is update the checkout action to use a fetch-depth of 0, which means, “grab all the git history”. That’s a lot missing we’ll require that we want to read (to infer PR titles, and commits, and all sorts of cool stuff below). ![]() Actions/checkout fetches the most recent version of files, but leaves the branch in a detached head state, and also doesn’t clone the git history.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |