diff --git a/README.md b/README.md index 72ad3df..9f5342b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,9 @@ jobs: | author_name | string | 'github-actions[bot]' | Name used to configure user.name in `git config`. | | coauthor_email | string | | Email used to make a co-authored commit. | | coauthor_name | string | | Name used to make a co-authored commit. | +| message | string | 'chore: autopublish ${date}' | Commit message. | | branch | string | 'master' | Destination branch to push changes. | +| empty | boolean | false | Allow empty commit. | | force | boolean | false | Determines if force push is used. | | tags | boolean | false | Determines if `--tags` is used. | | directory | string | '.' | Directory to change to before pushing. | diff --git a/action.yml b/action.yml index fd74154..8e06749 100644 --- a/action.yml +++ b/action.yml @@ -15,10 +15,13 @@ inputs: required: false coauthor_email: description: 'Email used to make a co-authored commit.' - required: false + required: false coauthor_name: description: 'Name used to make a co-authored commit.' required: false + message: + description: 'Commit message.' + required: false repository: description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})' default: '' @@ -27,6 +30,9 @@ inputs: description: 'Destination branch to push changes' required: false default: 'master' + empty: + description: 'Allow empty commit' + required: false force: description: 'Determines if force push is used' required: false diff --git a/start.sh b/start.sh index f5a968b..5e9bbed 100644 --- a/start.sh +++ b/start.sh @@ -1,15 +1,18 @@ #!/bin/sh set -e +timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + INPUT_AUTHOR_EMAIL=${INPUT_AUTHOR_EMAIL:-'github-actions[bot]@users.noreply.github.com'} INPUT_AUTHOR_NAME=${INPUT_AUTHOR_NAME:-'github-actions[bot]'} INPUT_COAUTHOR_EMAIL=${INPUT_COAUTHOR_EMAIL:-''} INPUT_COAUTHOR_NAME=${INPUT_COAUTHOR_NAME:-''} +INPUT_MESSAGE=${INPUT_MESSAGE:-"chore: autopublish ${timestamp}"} INPUT_BRANCH=${INPUT_BRANCH:-master} INPUT_FORCE=${INPUT_FORCE:-false} INPUT_TAGS=${INPUT_TAGS:-false} +INPUT_EMPTY=${INPUT_EMPTY:-false} INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'} -_FORCE_OPTION='' REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY} echo "Push to branch $INPUT_BRANCH"; @@ -18,6 +21,10 @@ echo "Push to branch $INPUT_BRANCH"; exit 1; }; +if ${INPUT_EMPTY}; then + _EMPTY='--allow-empty' +fi + if ${INPUT_FORCE}; then _FORCE_OPTION='--force' fi @@ -34,17 +41,15 @@ git config http.sslVerify false git config --local user.email "${INPUT_AUTHOR_EMAIL}" git config --local user.name "${INPUT_AUTHOR_NAME}" -timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - git add -A if [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then - git commit -m "chore: autopublish ${timestamp} + git commit -m "${INPUT_MESSAGE} -Co-authored-by: ${INPUT_COAUTHOR_NAME} <${INPUT_COAUTHOR_EMAIL}>" || exit 0 +Co-authored-by: ${INPUT_COAUTHOR_NAME} <${INPUT_COAUTHOR_EMAIL}>" $_EMPTY || exit 0 else - git commit -m "chore: autopublish ${timestamp}" || exit 0 + git commit -m "{$INPUT_MESSAGE}" $_EMPTY || exit 0 fi git push "${remote_repo}" HEAD:"${INPUT_BRANCH}" --follow-tags $_FORCE_OPTION $_TAGS; \ No newline at end of file