Skip to content

Commit aa4fe8e

Browse files
authored
chore: Improve the PRs of automatic updates (#1406)
1 parent 33cfae2 commit aa4fe8e

File tree

5 files changed

+110
-21
lines changed

5 files changed

+110
-21
lines changed

.github/actions/diff/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## `diff` Action
2+
3+
Generate the git diff for the given files

.github/actions/diff/action.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: diff
2+
description: Generate Git Diff for specified files
3+
4+
inputs:
5+
path:
6+
description: Path of the files to `git diff`
7+
required: false
8+
9+
outputs:
10+
diff:
11+
description: The result of the git diff.
12+
value: ${{ steps.diff.outputs.git_diff }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Git Diff
18+
id: diff
19+
shell: bash
20+
env:
21+
FILES: ${{ inputs.path }}
22+
run: |
23+
echo 'git_diff<<@@GIT_STATUS@@' >> $GITHUB_OUTPUT
24+
git --no-pager diff $FILES >> $GITHUB_OUTPUT
25+
echo '@@GIT_STATUS@@' >> $GITHUB_OUTPUT

.github/actions/pr-body/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## `pr-body` Action
2+
3+
Generate a PR Body based upon the file diffs. Useful for dependency updates.

.github/actions/pr-body/action.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: gen-pr-body
2+
description: Generate a Pull Request body based upon the diff
3+
4+
inputs:
5+
message:
6+
description: The PR message
7+
required: false
8+
9+
title:
10+
description: The title
11+
required: false
12+
13+
path:
14+
description: Path of the files to `git diff`
15+
required: false
16+
17+
outputs:
18+
body:
19+
description: The resulting PR Body text
20+
value: ${{ steps.body.outputs.value }}
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- name: Git Diff
26+
id: diff
27+
uses: ./.github/actions/diff
28+
if: inputs.path
29+
with:
30+
path: ${{ inputs.path }}
31+
32+
- name: Section Diff
33+
id: section-diff
34+
if: inputs.path && steps.diff.outputs.diff
35+
uses: streetsidesoftware/actions/public/output@v1
36+
with:
37+
value: |
38+
## Selected Diffs
39+
40+
```diff
41+
${{ steps.diff.outputs.diff }}
42+
```
43+
44+
- name: Gen Summary
45+
shell: bash
46+
run: |
47+
echo 'git_summary<<DIFF' >> $GITHUB_ENV
48+
git --no-pager diff --compact-summary >> $GITHUB_ENV
49+
echo 'DIFF' >> $GITHUB_ENV
50+
51+
- name: Body
52+
id: body
53+
uses: streetsidesoftware/actions/public/output@v1
54+
with:
55+
value: |
56+
# ${{ inputs.title || 'Changes' }}
57+
58+
${{ inputs.message }}
59+
60+
${{ steps.section-diff.outputs.value }}
61+
62+
## Summary
63+
64+
```
65+
${{ env.git_summary }}
66+
```

.github/workflows/update-dependencies.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,24 @@ jobs:
5252
git --no-pager diff --compact-summary --exit-code && echo "git_status=clean" >> $GITHUB_ENV || echo "git_status=dirty" >> $GITHUB_ENV
5353
git --no-pager diff --compact-summary
5454
55-
- name: Gen Body
56-
run: |
57-
echo 'git_body<<DIFF' >> $GITHUB_ENV
58-
git --no-pager diff --compact-summary >> $GITHUB_ENV
59-
echo 'DIFF' >> $GITHUB_ENV
60-
61-
- name: Summary
62-
id: summary
63-
uses: streetsidesoftware/actions/public/output@v1
55+
- name: Gen PR Body
56+
id: body
57+
uses: ./.github/actions/pr-body
6458
with:
65-
value: |
66-
Type: ${{ env.PR_TYPE }}
59+
title: Update Dependencies
60+
message: |
61+
**Type:** ${{ env.PR_TYPE }}
6762
68-
Status: ${{ steps.git-status.outputs.isDirty && 'dirty' || 'clean' }}
69-
```
70-
${{ steps.git-status.outputs.status }}
71-
```
63+
**Status:** ${{ steps.git-status.outputs.isDirty && 'dirty' || 'clean' }}
64+
path: >-
65+
package.json
66+
action-src/package.json
67+
action/package.json
7268
73-
diff:
74-
```
75-
${{ env.git_body }}
76-
```
7769
- name: Show Summary
7870
uses: streetsidesoftware/actions/public/summary@v1
7971
with:
80-
text: ${{ steps.summary.outputs.value }}
72+
text: ${{ steps.body.outputs.body }}
8173

8274
- name: PR
8375
uses: streetsidesoftware/actions/.github/actions/pr@v1
@@ -86,6 +78,6 @@ jobs:
8678
branch: ${{ env.NEW_BRANCH }}
8779
base: ${{ env.REF_BRANCH }}
8880
title: "${{ env.PR_TYPE }}: Workflow Bot -- Update ALL Dependencies (${{ env.REF_BRANCH }})"
89-
body: ${{ steps.summary.outputs.value }}
81+
body: ${{ steps.body.outputs.body }}
9082
app_id: ${{ secrets.AUTOMATION_APP_ID }}
9183
app_private_key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}

0 commit comments

Comments
 (0)