Skip to content

Commit e094bec

Browse files
committed
feat: update README workflow to include commit description with heredoc support
- fix description
1 parent b0f1390 commit e094bec

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

.github/workflows/update_readme.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11
name: Add information from latest push in a branch into main readme
2-
32
on:
43
push:
54
branches:
65
- front-end
7-
86
jobs:
97
update-readme:
108
runs-on: ubuntu-latest
11-
129
steps:
1310
- name: Checkout main branch
1411
uses: actions/checkout@v4
1512
with:
1613
ref: main
1714
token: ${{secrets.GITHUB_TOKEN}}
15+
1816
- name: Get latest commit
1917
id: commit_info
2018
run: |
2119
git fetch origin "front-end"
22-
2320
BRANCH="front-end"
2421
MESSAGE=$(git log origin/"front-end" -1 --pretty=%s)
25-
DESCRIPTION=$(git log origin/"front-end" -1 --pretty=%b)
2622
ID=$(git log origin/"front-end" -1 --pretty=%H)
2723
SHORT_ID=$(git log origin/"front-end" -1 --pretty=%h)
2824
URL="${{github.server_url}}/${{github.repository}}"
2925
26+
# Use heredoc format for multiline GITHUB_OUTPUT
3027
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
3128
echo "message=$MESSAGE" >> $GITHUB_OUTPUT
32-
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
3329
echo "id=$ID" >> $GITHUB_OUTPUT
3430
echo "short_id=$SHORT_ID" >> $GITHUB_OUTPUT
3531
echo "url=$URL" >> $GITHUB_OUTPUT
3632
33+
# Handle description with heredoc to support multiline and special characters
34+
{
35+
echo 'description<<EOF'
36+
git log origin/"front-end" -1 --pretty=%b
37+
echo EOF
38+
} >> $GITHUB_OUTPUT
39+
3740
- name: Update README
3841
run: |
3942
# Create or update the development section in README
4043
cat > dev-info.md << 'EOF'
4144
## Currently in Development
42-
4345
**Branch:** ${{ steps.commit_info.outputs.branch }}
4446
**Commit:** ${{ steps.commit_info.outputs.message }}
4547
**Description:** ${{ steps.commit_info.outputs.description }}
4648
**Commit ID:** `${{ steps.commit_info.outputs.short_id }}`
47-
4849
[View Branch](${{ steps.commit_info.outputs.url }}/tree/front-end) | [View Commit](${{ steps.commit_info.outputs.url }}/commit/${{ steps.commit_info.outputs.id }})
49-
5050
---
51-
5251
EOF
5352
5453
# If README.md exists, prepend the dev info
@@ -62,7 +61,6 @@ jobs:
6261
# Create new README with dev info
6362
mv dev-info.md README.md
6463
fi
65-
6664
rm -f dev-info.md
6765
6866
- name: Commit and push changes

0 commit comments

Comments
 (0)