Repository navigation
Add option to use GitHub Actor instead of name from the inputs #5
Description
Activity
- addedtype: featureNew feature or feature requestNew feature or feature request
on Dec 5, 2019 I think a better solution would be to use the GitHub Event and find the author of the head commit with jq.
Dockerfile:FROM alpine/git:1.0.7 LABEL "com.github.actions.name"="Add & Commit" LABEL "com.github.actions.description"="Add & commit files from a path directly from GitHub Actions" LABEL "com.github.actions.icon"="git-commit" LABEL "com.github.actions.color"="black" LABEL "repository"="https://github.com/EndBug/add-and-commit" LABEL "homepage"="https://github.com/EndBug/add-and-commit" LABEL "maintainer"="Federico Grandi <fgrandi30@gmail.com>" RUN apk add jq COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["sh", "/entrypoint.sh"]In
entrypoint.sh:echo "fetching author, name and email" AUTHOR_EMAIL=$(cat "$GITHUB_EVENT_PATH" | jq '.head_commit.author.email' | sed 's/"//g') AUTHOR_NAME=$(cat "$GITHUB_EVENT_PATH" | jq '.head_commit.author.name' | sed 's/"//g') echo "'$AUTHOR_NAME' and '$AUTHOR_EMAIL'" .... git config --global user.email "$AUTHOR_EMAIL" git config --global user.name "$AUTHOR_NAME"I hope you can come to terms with why the action does not work after my additions. It fails during staging (?). The fork of your repository where I have applied these changes:
##[error]Docker run failed with exit code 1
Run jactor-rises/add-and-commit@master
with:
message: Fresh build after commit on master by jactor-rises
path: .
force: false
pattern: .
env:
GITHUB_TOKEN: ***
/usr/bin/docker run --name af96b48018bbcf9e214994a8619432ae4ef2bc_8f2498 --label af96b4 --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_MESSAGE -e INPUT_PATH -e INPUT_FORCE -e INPUT_PATTERN -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/actions/actions":"/github/workspace" af96b4:8018bbcf9e214994a8619432ae4ef2bc
fetching author, name and email
'Tor Egil Jacobsen' and 'tor.egil.jacobsen@nav.no'
Staging files in commit path...
The following paths are ignored by one of your .gitignore files:
action-build-for-commit/node_modules/@actions/core/lib/core.d.ts
Use -f if you really want to add them.
##[error]Docker run failed with exit code 1@jactor-rises It may be because you're using
.as the pattern. Try changing it to something like*.js, or even*.*: if you only use the dot it ends up withworking/directory/./.which may be the thing causing the error.If that fixes the thing, you're welcome to open a PR that closes this issue, I really like your solution :)
Yeah, I noticed it too...
I was planning to do a rewrite in TypeScript someday, but I couldn't find the time lolAnyway, thanks for your contribution, send me a message if you need any help :)
Using the
GITHUB_ACTORenvironment variable would allow for the commit to be assigned to the person who triggered the action run, instead of the user assigned in the workflow. It needs to be an option that overrides any name/email provided.