Skip to content

Commit b2743a2

Browse files
committed
fix: only create flake.lock PR if there are actually changes
1 parent 3c5ef63 commit b2743a2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

.github/workflows/update-flake-dependencies.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ jobs:
2222
COMMIT_BRANCH: automation/update-flake-dependencies
2323
COMMIT_MESSAGE: "chore(nix): Update Flake dependencies"
2424
run: |
25-
# create the branch on the remote
26-
git branch "$COMMIT_BRANCH"
27-
git push -u origin "$COMMIT_BRANCH"
28-
# commit via the GitHub API so we get automatic commit signing
29-
gh api --method PUT /repos/1Password/shell-plugins/contents/$FILE_TO_COMMIT \
30-
--field message="$COMMIT_MESSAGE" \
31-
--field content=@<(base64 -i $FILE_TO_COMMIT) \
32-
--field branch="$COMMIT_BRANCH" \
33-
--field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
34-
gh pr create --title "[automation]: Update Flake dependencies" --body "This is an automated PR to update \`flake.lock\`" --reviewer mrjones2014 --base main --head $COMMIT_BRANCH
25+
# make sure something actually changed first, if not, no updates required
26+
if [[ `git status --porcelain` ]]; then
27+
# create the branch on the remote
28+
git branch "$COMMIT_BRANCH"
29+
git push -u origin "$COMMIT_BRANCH"
30+
# commit via the GitHub API so we get automatic commit signing
31+
gh api --method PUT /repos/1Password/shell-plugins/contents/$FILE_TO_COMMIT \
32+
--field message="$COMMIT_MESSAGE" \
33+
--field content=@<(base64 -i $FILE_TO_COMMIT) \
34+
--field branch="$COMMIT_BRANCH" \
35+
--field sha="$(git rev-parse $COMMIT_BRANCH:$FILE_TO_COMMIT)"
36+
gh pr create --title "[automation]: Update Flake dependencies" --body "This is an automated PR to update \`flake.lock\`" --reviewer mrjones2014 --base main --head $COMMIT_BRANCH
37+
fi

0 commit comments

Comments
 (0)