Merge pull request #138 from sleepypikachu/master

Add atomic push
This commit is contained in:
Pascal Zimmermann 2022-10-04 15:00:23 +02:00 committed by GitHub
commit 35284cf030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -95,6 +95,7 @@ jobs:
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
| force | boolean | false | Determines if force push is used. |
| force_with_lease | boolean | false | Determines if force-with-lease push is used. Please specify the corresponding branch inside `ref` section of the checkout action e.g. `ref: ${{ github.head_ref }}`. |
| atomic | boolean | true | Determines if [atomic](https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-atomic) push is used. |
| tags | boolean | false | Determines if `--tags` is used. |
| directory | string | '.' | Directory to change to before pushing. |
| repository | string | '' | Repository name. <br /> Default or empty repository name represents <br /> current github repository. <br /> If you want to push to other repository, <br /> you should make a [personal access token](https://github.com/settings/tokens) <br /> and use it as the `github_token` input. |

View File

@ -29,6 +29,9 @@ inputs:
force_with_lease:
description: 'Determines if force-with-lease push is used'
required: false
atomic:
description: 'Determines if atomic push is used, default true'
required: false
tags:
description: 'Determines if --tags is used'
required: false

View File

@ -1,11 +1,13 @@
#!/bin/sh
set -e
INPUT_ATOMIC=${INPUT_ATOMIC:-true}
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_FORCE_WITH_LEASE=${INPUT_FORCE_WITH_LEASE:-false}
INPUT_SSH=${INPUT_SSH:-false}
INPUT_TAGS=${INPUT_TAGS:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
_ATOMIC_OPTION=''
_FORCE_OPTION=''
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
@ -20,6 +22,10 @@ if ${INPUT_FORCE} && ${INPUT_FORCE_WITH_LEASE}; then
exit 1;
fi
if ${INPUT_ATOMIC}; then
_ATOMIC_OPTION='--atomic'
fi
if ${INPUT_FORCE}; then
_FORCE_OPTION='--force'
fi
@ -41,7 +47,7 @@ else
fi
if ${INPUT_FORCE_WITH_LEASE}; then
git push --follow-tags $_FORCE_OPTION $_TAGS;
git push $_ATOMIC_OPTION --follow-tags $_FORCE_OPTION $_TAGS;
else
git push "${remote_repo}" HEAD:${INPUT_BRANCH} --verbose --follow-tags $_FORCE_OPTION $_TAGS;
git push "${remote_repo}" HEAD:${INPUT_BRANCH} $_ATOMIC_OPTION --verbose --follow-tags $_FORCE_OPTION $_TAGS;
fi