Skip to content

Commit f7aaa2a

Browse files
authored
Merge pull request #6 from ouuan/allow_empty_commits
Add an option "allow_empty_commits"
2 parents 610072e + 84a7f5b commit f7aaa2a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ GitHub Actions to publish AUR package.
2828

2929
**Optional** Commit message to use when creating the new commit.
3030

31+
### `allow_empty_commits`
32+
33+
**Optional** Allow empty commits, i.e. commits with no change. The default value is `true`.
34+
3135
### `ssh_keyscan_types`
3236

3337
**Optional** Comma-separated list of types to use when adding aur.archlinux.org to known hosts.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: 'Commit message to use when creating the new commit'
2525
required: false
2626
default: 'Update PKGBUILD and .SRCINFO with GitHub Actions'
27+
allow_empty_commits:
28+
description: 'Allow empty commits, i.e. commits with no change.'
29+
required: false
30+
default: 'true'
2731
ssh_keyscan_types:
2832
description: 'Comma-separated list of types to use when adding aur.archlinux.org to known hosts'
2933
required: false

build.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ commit_username=$INPUT_COMMIT_USERNAME
88
commit_email=$INPUT_COMMIT_EMAIL
99
ssh_private_key=$INPUT_SSH_PRIVATE_KEY
1010
commit_message=$INPUT_COMMIT_MESSAGE
11+
allow_empty_commits=$INPUT_ALLOW_EMPTY_COMMITS
1112
ssh_keyscan_types=$INPUT_SSH_KEYSCAN_TYPES
1213

1314
export HOME=/home/builder
@@ -49,6 +50,10 @@ echo '::endgroup::'
4950
echo '::group::Publishing'
5051
git remote add aur "ssh://aur@aur.archlinux.org/${pkgname}.git"
5152
git add -fv PKGBUILD .SRCINFO
52-
git commit --allow-empty -m "$commit_message"
53-
git push -fv aur master
53+
case "$allow_empty_commits" in
54+
true) git commit --allow-empty -m "$commit_message";;
55+
false) git diff-index --quiet HEAD || git commit -m "$commit_message";; # use `git diff-index --quiet HEAD ||` to avoid error
56+
*) echo 'The option "allow_empty_commits" should be either "true" or "false".' && false;;
57+
esac
58+
git push --force-with-lease -v aur master
5459
echo '::endgroup::'

0 commit comments

Comments
 (0)