Skip to content

Commit 0b5295d

Browse files
committed
Refactor commit message to use environment variables with multi-line content
- Add commit message file to store and read the commit message - Refactor gh pr create command to use env variables directly
1 parent 91b9356 commit 0b5295d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

.github/workflows/create-pr-on-push-to-develop.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
run: |
2626
COMMIT_SHA=$(git rev-parse HEAD)
2727
COMMIT_TITLE=$(git log -1 --pretty=format:'%s' $COMMIT_SHA)
28-
COMMIT_MESSAGE=$(git log -1 --pretty=format:'%b' $COMMIT_SHA)
28+
COMMIT_MESSAGE=$(git log -1 --pretty=format:'%B' $COMMIT_SHA)
2929
COMMIT_AUTHOR=$(git log -1 --pretty=format:'%an' $COMMIT_SHA)
3030
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_ENV
3131
echo "commit_title=${COMMIT_TITLE}" >> $GITHUB_ENV
32-
echo "commit_message=${COMMIT_MESSAGE}" >> $GITHUB_ENV
3332
echo "commit_author=${COMMIT_AUTHOR}" >> $GITHUB_ENV
33+
echo "${COMMIT_MESSAGE}" > commit_message.txt
3434
3535
- name: Map commit author to GitHub username
3636
id: map_author
@@ -53,7 +53,7 @@ jobs:
5353
LABEL_KEYWORDS["wontfix"]="wontfix"
5454
5555
COMMIT_TITLE="${{ env.commit_title }}"
56-
COMMIT_MESSAGE="${{ env.commit_message }}"
56+
COMMIT_MESSAGE=$(cat commit_message.txt) # Read commit message from the file
5757
5858
LABELS=""
5959
@@ -70,4 +70,5 @@ jobs:
7070
- name: Create pull request
7171
id: create_pr
7272
run: |
73-
gh pr create --head ${{ env.BRANCH_NAME }} --base main -t "$commit_title" -b "$commit_message" -a "$GITHUB_USERNAME" -l "$LABELS"
73+
COMMIT_MESSAGE=$(cat commit_message.txt) # Read commit message from the file
74+
gh pr create --head ${{ env.BRANCH_NAME }} --base main -t "${{ env.commit_title }}" -b "$COMMIT_MESSAGE" -a "${{ env.GITHUB_USERNAME }}" -l "${{ env.LABELS }}"

0 commit comments

Comments
 (0)