@@ -13,20 +13,28 @@ jobs:
1313 - uses : actions/checkout@v4
1414 - uses : DeterminateSystems/nix-installer-action@main
1515 - uses : DeterminateSystems/magic-nix-cache-action@main
16- - name : update flake.lock
17- run : nix flake update
18- - name : Create signed commit with flake.lock changes
16+ - name : Update flake.lock and create signed commit with flake.lock changes
1917 env :
2018 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2119 FILE_TO_COMMIT : flake.lock
2220 COMMIT_BRANCH : automation/update-flake-dependencies
2321 COMMIT_MESSAGE : " chore(nix): Update Flake dependencies"
2422 run : |
23+ # fetch remote state
24+ git fetch
25+ # if branch exists on remote already
26+ if git checkout "$COMMIT_BRANCH" > /dev/null 2>&1; then
27+ # pull changes
28+ git pull
29+ else
30+ # otherwise, create the branch and push it to remote
31+ git checkout -b "$COMMIT_BRANCH"
32+ git push -u origin "$COMMIT_BRANCH"
33+ fi
34+ # update flake.lock
35+ nix flake update
2536 # make sure something actually changed first, if not, no updates required
2637 if [[ `git status --porcelain` ]]; then
27- # create the branch on the remote
28- git branch "$COMMIT_BRANCH"
29- git push -u origin "$COMMIT_BRANCH"
3038 # commit via the GitHub API so we get automatic commit signing
3139 gh api --method PUT /repos/1Password/shell-plugins/contents/$FILE_TO_COMMIT \
3240 --field message="$COMMIT_MESSAGE" \
0 commit comments