Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Configurable gh author #154

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ keep_files: [.git, hello.html]
### bundler_version
When set override the default bundler version provided. If not given will attempt to resolve bundler version from `Gemfile.lock` if one exists.

### commit_author
When set override the default author of the commits to be performed. The default is to use the `GITHUB_ACTOR` environment variable, which is usually the owner of the `GITHUB_TOKEN` secret. The value can for example be set to `github-actions[bot]`. The corresponding email address is automatically set to `[commit_author]@users.noreply.github.com`.

## Use case: multi version publishing

Say you want to create a documentation website where you both have the current version (`v3.0`), but also `v1.0` and `v2.0`. You can then use a combination of `keep_history` and `target_path` along with the `actions/checkout@v2`action so that each version gets pushed in a separate folder without overwritting the previous one.
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ inputs:
bundler_version:
description: 'When set override the default bundler version provided.'
required: false
commit_author:
description: >
Provide an author for commits by the action.
The email address is automatically set to
`[author name]@users.noreply.github.com`
required: false
outputs:
sha:
description: 'Generated commit SHA1 that will be published'
Expand Down
11 changes: 9 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,15 @@ touch .nojekyll

echo "Publishing to ${GITHUB_REPOSITORY} on branch ${remote_branch}"

git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
if [ -n "$INPUT_COMMIT_AUTHOR" ]; then
git config user.name "${INPUT_COMMIT_AUTHOR}" && \
git config user.email "${INPUT_COMMIT_AUTHOR}@users.noreply.github.com" && \
echo "::debug::commit author is set via input parameter"
else
git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
echo "::debug::commit author is set to the default github actor"
fi
git add . && \
git commit $COMMIT_OPTIONS -m "jekyll build from Action ${GITHUB_SHA}" && \
git push $PUSH_OPTIONS $REMOTE_REPO $LOCAL_BRANCH:$remote_branch && \
Expand Down