Skip to content

Commit dcf331c

Browse files
committed
refactor: initialize Git variable in a single place
Relate to #1610
1 parent 7335f67 commit dcf331c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

+10-9
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,25 @@ jobs:
108108
# Make variable available for the next steps
109109
echo "PUZZLES_FILES_MODIFIED=$PUZZLES_FILES_MODIFIED" | tee -a "$GITHUB_ENV"
110110
111-
- name: Collect information about the original commit
111+
- name: Initialize Git variables for committing the changes
112112
if: env.PUZZLES_FILES_MODIFIED == 'yes'
113113
run: |
114+
COMMIT_MSG="$(git show "$GITHUB_SHA" --no-patch --format=oneline --abbrev-commit)"
115+
AUTHOR_EMAIL="$(git show "$GITHUB_SHA" --no-patch --format=%aE)"
116+
AUTHOR_NAME="$(git show "$GITHUB_SHA" --no-patch --format=%aN)"
117+
114118
# Make variables available for the next steps
115119
(
116-
echo "COMMIT_MSG=$(git show "$GITHUB_SHA" --no-patch --format=oneline --abbrev-commit)"
117-
echo "AUTHOR_EMAIL=$(git show "$GITHUB_SHA" --no-patch --format=%aE)"
118-
echo "AUTHOR_NAME=$(git show "$GITHUB_SHA" --no-patch --format=%aN)"
120+
echo "GIT_AUTHOR_NAME=GitHub Action on behalf of $AUTHOR_NAME"
121+
echo "GIT_COMMITTER_NAME=GitHub Action on behalf of $AUTHOR_NAME"
122+
echo "GIT_AUTHOR_EMAIL=$AUTHOR_EMAIL"
123+
echo "GIT_COMMITTER_EMAIL=$AUTHOR_EMAIL"
119124
) | tee -a "$GITHUB_ENV"
120125
121126
- name: Commit the changes
122127
if: env.PUZZLES_FILES_MODIFIED == 'yes'
123128
env:
124-
GIT_AUTHOR_NAME: "GitHub Action on behalf of ${{ env.AUTHOR_NAME }}"
125-
GIT_COMMITTER_NAME: "GitHub Action on behalf of ${{ env.AUTHOR_NAME }}"
126-
GIT_AUTHOR_EMAIL: "${{ env.AUTHOR_EMAIL }}"
127-
GIT_COMMITTER_EMAIL: "${{ env.AUTHOR_EMAIL }}"
128-
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
129+
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
129130
working-directory: generated-todos
130131
run: |
131132
for FILE in pdd.xml todos-in-code.tsv; do

0 commit comments

Comments
 (0)