Skip to content

Commit 0fd60da

Browse files
committed
refactor: initialize Git variable in a single place
Relate to #1610
1 parent d106ee3 commit 0fd60da

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

.github/workflows/todos-extract-from-code.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,25 @@ jobs:
9595
# Make variable available for the next steps
9696
echo "PUZZLES_FILES_MODIFIED=$PUZZLES_FILES_MODIFIED" | tee -a "$GITHUB_ENV"
9797
98-
- name: Collect information about the original commit
98+
- name: Initialize Git variables for committing the changes
9999
if: env.PUZZLES_FILES_MODIFIED == 'yes'
100100
run: |
101+
AUTHOR_EMAIL="$(git show "$GITHUB_SHA" --no-patch --format=%aE)"
102+
AUTHOR_NAME="$(git show "$GITHUB_SHA" --no-patch --format=%aN)"
103+
101104
# Make variables available for the next steps
102105
(
103106
echo "COMMIT_MSG=$(git show "$GITHUB_SHA" --no-patch --format=oneline --abbrev-commit)"
104-
echo "AUTHOR_EMAIL=$(git show "$GITHUB_SHA" --no-patch --format=%aE)"
105-
echo "AUTHOR_NAME=$(git show "$GITHUB_SHA" --no-patch --format=%aN)"
107+
echo "GIT_AUTHOR_NAME=GitHub Action on behalf of $AUTHOR_NAME"
108+
echo "GIT_COMMITTER_NAME=GitHub Action on behalf of $AUTHOR_NAME"
109+
echo "GIT_AUTHOR_EMAIL=$AUTHOR_EMAIL"
110+
echo "GIT_COMMITTER_EMAIL=$AUTHOR_EMAIL"
106111
) | tee -a "$GITHUB_ENV"
107112
108113
- name: Commit the changes
109114
if: env.PUZZLES_FILES_MODIFIED == 'yes'
110115
env:
111-
GIT_AUTHOR_NAME: "GitHub Action on behalf of ${{ env.AUTHOR_NAME }}"
112-
GIT_COMMITTER_NAME: "GitHub Action on behalf of ${{ env.AUTHOR_NAME }}"
113-
GIT_AUTHOR_EMAIL: "${{ env.AUTHOR_EMAIL }}"
114-
GIT_COMMITTER_EMAIL: "${{ env.AUTHOR_EMAIL }}"
115-
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
116+
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
116117
working-directory: generated-todos
117118
run: |
118119
for FILE in pdd.xml todos-in-code.tsv; do

0 commit comments

Comments
 (0)