|
1 | 1 | name: Add information from latest push in a branch into main readme |
2 | | - |
3 | 2 | on: |
4 | 3 | push: |
5 | 4 | branches: |
6 | 5 | - front-end |
7 | | - |
8 | 6 | jobs: |
9 | 7 | update-readme: |
10 | 8 | runs-on: ubuntu-latest |
11 | | - |
12 | 9 | steps: |
13 | 10 | - name: Checkout main branch |
14 | 11 | uses: actions/checkout@v4 |
15 | 12 | with: |
16 | 13 | ref: main |
17 | 14 | token: ${{secrets.GITHUB_TOKEN}} |
| 15 | + |
18 | 16 | - name: Get latest commit |
19 | 17 | id: commit_info |
20 | 18 | run: | |
21 | 19 | git fetch origin "front-end" |
22 | | -
|
23 | 20 | BRANCH="front-end" |
24 | 21 | MESSAGE=$(git log origin/"front-end" -1 --pretty=%s) |
25 | | - DESCRIPTION=$(git log origin/"front-end" -1 --pretty=%b) |
26 | 22 | ID=$(git log origin/"front-end" -1 --pretty=%H) |
27 | 23 | SHORT_ID=$(git log origin/"front-end" -1 --pretty=%h) |
28 | 24 | URL="${{github.server_url}}/${{github.repository}}" |
29 | 25 |
|
| 26 | + # Use heredoc format for multiline GITHUB_OUTPUT |
30 | 27 | echo "branch=$BRANCH" >> $GITHUB_OUTPUT |
31 | 28 | echo "message=$MESSAGE" >> $GITHUB_OUTPUT |
32 | | - echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT |
33 | 29 | echo "id=$ID" >> $GITHUB_OUTPUT |
34 | 30 | echo "short_id=$SHORT_ID" >> $GITHUB_OUTPUT |
35 | 31 | echo "url=$URL" >> $GITHUB_OUTPUT |
36 | 32 |
|
| 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 | +
|
37 | 40 | - name: Update README |
38 | 41 | run: | |
39 | 42 | # Create or update the development section in README |
40 | 43 | cat > dev-info.md << 'EOF' |
41 | 44 | ## Currently in Development |
42 | | -
|
43 | 45 | **Branch:** ${{ steps.commit_info.outputs.branch }} |
44 | 46 | **Commit:** ${{ steps.commit_info.outputs.message }} |
45 | 47 | **Description:** ${{ steps.commit_info.outputs.description }} |
46 | 48 | **Commit ID:** `${{ steps.commit_info.outputs.short_id }}` |
47 | | -
|
48 | 49 | [View Branch](${{ steps.commit_info.outputs.url }}/tree/front-end) | [View Commit](${{ steps.commit_info.outputs.url }}/commit/${{ steps.commit_info.outputs.id }}) |
49 | | -
|
50 | 50 | --- |
51 | | -
|
52 | 51 | EOF |
53 | 52 |
|
54 | 53 | # If README.md exists, prepend the dev info |
|
62 | 61 | # Create new README with dev info |
63 | 62 | mv dev-info.md README.md |
64 | 63 | fi |
65 | | -
|
66 | 64 | rm -f dev-info.md |
67 | 65 |
|
68 | 66 | - name: Commit and push changes |
|
0 commit comments