Skip to content

Commit 02c737d

Browse files
[github-actions] Add workflow step summaries (#148) (#173)
* [github-actions] Add workflow step summaries (#148) * [docs] Remove duplicated review automation entries (#148) * [github-actions] Fix summary action execute bit (#148) * [github-actions] Checkout before local summary actions (#148) * [github-actions] Build reports summary markdown safely (#148) * Update wiki submodule pointer for PR #173 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e3b59c6 commit 02c737d

19 files changed

Lines changed: 269 additions & 13 deletions

File tree

.github/actions/changelog/publish-release/action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@ inputs:
1616
runs:
1717
using: composite
1818
steps:
19-
- name: Publish release
19+
- id: publish
20+
name: Publish release
2021
shell: bash
2122
env:
2223
GH_TOKEN: ${{ github.token }}
2324
INPUT_VERSION: ${{ inputs.version }}
2425
INPUT_TARGET: ${{ inputs.target }}
2526
INPUT_NOTES_FILE: ${{ inputs.notes-file }}
2627
run: ${{ github.action_path }}/run.sh
28+
29+
outputs:
30+
operation:
31+
description: Whether the release was created or updated.
32+
value: ${{ steps.publish.outputs.operation }}
33+
url:
34+
description: URL of the published GitHub release.
35+
value: ${{ steps.publish.outputs.url }}

.github/actions/changelog/publish-release/run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ set -euo pipefail
44
release_tag="v${INPUT_VERSION}"
55

66
if gh release view "${release_tag}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
7+
operation="updated"
78
gh release edit "${release_tag}" \
89
--repo "${GITHUB_REPOSITORY}" \
910
--title "${release_tag}" \
1011
--notes-file "${INPUT_NOTES_FILE}"
1112
else
13+
operation="created"
1214
gh release create "${release_tag}" \
1315
--repo "${GITHUB_REPOSITORY}" \
1416
--target "${INPUT_TARGET}" \
1517
--title "${release_tag}" \
1618
--notes-file "${INPUT_NOTES_FILE}"
1719
fi
20+
21+
release_url="$(gh release view "${release_tag}" --repo "${GITHUB_REPOSITORY}" --json url --jq '.url')"
22+
23+
echo "operation=${operation}" >> "${GITHUB_OUTPUT}"
24+
echo "url=${release_url}" >> "${GITHUB_OUTPUT}"

.github/actions/github-pages/cleanup-orphaned-previews/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ inputs:
99
runs:
1010
using: composite
1111
steps:
12-
- name: Cleanup orphaned previews
12+
- id: cleanup
13+
name: Cleanup orphaned previews
1314
shell: bash
1415
env:
1516
INPUT_PATH: ${{ inputs.path }}
1617
GH_TOKEN: ${{ github.token }}
1718
run: ${{ github.action_path }}/run.sh
19+
20+
outputs:
21+
deleted:
22+
description: Number of deleted preview directories.
23+
value: ${{ steps.cleanup.outputs.deleted }}
24+
skipped:
25+
description: Number of retained preview directories.
26+
value: ${{ steps.cleanup.outputs.skipped }}
27+
unresolved:
28+
description: Number of unresolved preview directories.
29+
value: ${{ steps.cleanup.outputs.unresolved }}

.github/actions/github-pages/cleanup-orphaned-previews/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ done < <(find previews -mindepth 1 -maxdepth 1 -type d -name 'pr-*' | sort)
4646

4747
echo "Preview cleanup summary: deleted=${deleted}, skipped=${skipped}, unresolved=${unresolved}."
4848

49+
echo "deleted=${deleted}" >> "${GITHUB_OUTPUT}"
50+
echo "skipped=${skipped}" >> "${GITHUB_OUTPUT}"
51+
echo "unresolved=${unresolved}" >> "${GITHUB_OUTPUT}"
52+
4953
touch .nojekyll
5054
git config user.name "github-actions[bot]"
5155
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Write Workflow Step Summary
2+
description: Append deterministic Markdown to GITHUB_STEP_SUMMARY when content is available.
3+
4+
inputs:
5+
markdown:
6+
description: Markdown content to append to the workflow step summary.
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Append summary
13+
shell: bash
14+
env:
15+
INPUT_MARKDOWN: ${{ inputs.markdown }}
16+
run: ${{ github.action_path }}/run.sh
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ -z "${INPUT_MARKDOWN}" ]; then
5+
exit 0
6+
fi
7+
8+
printf '%s\n' "${INPUT_MARKDOWN}" >> "${GITHUB_STEP_SUMMARY}"

.github/actions/wiki/cleanup-orphaned-previews/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ description: Delete wiki preview branches for pull requests that are no longer o
44
runs:
55
using: composite
66
steps:
7-
- name: Cleanup orphaned previews
7+
- id: cleanup
8+
name: Cleanup orphaned previews
89
shell: bash
910
env:
1011
GH_TOKEN: ${{ github.token }}
1112
working-directory: .github/wiki
1213
run: ${{ github.action_path }}/run.sh
14+
15+
outputs:
16+
deleted:
17+
description: Number of deleted preview branches.
18+
value: ${{ steps.cleanup.outputs.deleted }}
19+
skipped:
20+
description: Number of retained preview branches.
21+
value: ${{ steps.cleanup.outputs.skipped }}
22+
unresolved:
23+
description: Number of unresolved preview branches.
24+
value: ${{ steps.cleanup.outputs.unresolved }}

.github/actions/wiki/cleanup-orphaned-previews/run.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ set -euo pipefail
33

44
git fetch origin '+refs/heads/pr-*:refs/remotes/origin/pr-*' || true
55

6-
git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-* | while read -r remote_branch; do
6+
deleted=0
7+
skipped=0
8+
unresolved=0
9+
10+
while read -r remote_branch; do
711
branch="${remote_branch#origin/}"
812
pull_request_number="${branch#pr-}"
913

1014
if ! [[ "${pull_request_number}" =~ ^[0-9]+$ ]]; then
1115
echo "Skipping non-PR wiki preview branch ${branch}."
16+
skipped=$((skipped + 1))
1217
continue
1318
fi
1419

@@ -18,12 +23,19 @@ git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-* | while re
1823
CLOSED|MERGED)
1924
echo "Deleting wiki preview branch ${branch} for ${state} pull request #${pull_request_number}."
2025
git push origin --delete "${branch}" || true
26+
deleted=$((deleted + 1))
2127
;;
2228
OPEN)
2329
echo "Keeping wiki preview branch ${branch} for open pull request #${pull_request_number}."
30+
skipped=$((skipped + 1))
2431
;;
2532
*)
2633
echo "Could not resolve pull request #${pull_request_number} for wiki preview branch ${branch}. Keeping it."
34+
unresolved=$((unresolved + 1))
2735
;;
2836
esac
29-
done
37+
done < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-*)
38+
39+
echo "deleted=${deleted}" >> "${GITHUB_OUTPUT}"
40+
echo "skipped=${skipped}" >> "${GITHUB_OUTPUT}"
41+
echo "unresolved=${unresolved}" >> "${GITHUB_OUTPUT}"

.github/wiki

Submodule wiki updated from e4312aa to 2a1fdf6

.github/workflows/changelog.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ jobs:
107107
BASE_REF: ${{ github.event.pull_request.base.ref }}
108108
run: composer dev-tools changelog:check -- --file="${CHANGELOG_FILE}" --against="origin/${BASE_REF}"
109109

110+
- uses: ./.github/actions/summary/write
111+
with:
112+
markdown: |
113+
## Changelog Validation Summary
114+
115+
- Changelog file: `${{ env.CHANGELOG_FILE }}`
116+
- Compared base ref: `origin/${{ github.event.pull_request.base.ref }}`
117+
- Validation result: success
118+
110119
prepare_release_pull_request:
111120
name: Prepare Release Pull Request
112121
needs: resolve_php
@@ -181,11 +190,16 @@ jobs:
181190
from-status: Merged
182191
to-status: Release Prepared
183192

184-
- name: Summarize prepared release
185-
run: |
186-
echo "Prepared release version: ${{ steps.version.outputs.value }}"
187-
echo "Pull request operation: ${{ steps.create_pr.outputs.pull-request-operation || 'none' }}"
188-
echo "Pull request URL: ${{ steps.create_pr.outputs.pull-request-url || 'not created' }}"
193+
- uses: ./.github/actions/summary/write
194+
with:
195+
markdown: |
196+
## Release Preparation Summary
197+
198+
- Changelog file: `${{ env.CHANGELOG_FILE }}`
199+
- Release version: `${{ steps.version.outputs.value }}`
200+
- Version source: `${{ steps.version.outputs.source }}`
201+
- Pull request operation: `${{ steps.create_pr.outputs.pull-request-operation || 'none' }}`
202+
- Pull request URL: ${{ steps.create_pr.outputs.pull-request-url || 'not created' }}
189203
190204
publish_merged_release:
191205
name: Publish Merged Release
@@ -225,6 +239,7 @@ jobs:
225239
version: ${{ steps.version.outputs.value }}
226240

227241
- name: Publish GitHub release
242+
id: publish_release
228243
uses: ./.github/actions/changelog/publish-release
229244
with:
230245
version: ${{ steps.version.outputs.value }}
@@ -238,3 +253,13 @@ jobs:
238253
from-status: Release Prepared
239254
to-status: Released
240255
include-current-pull-request: 'true'
256+
257+
- uses: ./.github/actions/summary/write
258+
with:
259+
markdown: |
260+
## Release Publication Summary
261+
262+
- Changelog file: `${{ env.CHANGELOG_FILE }}`
263+
- Published tag: `v${{ steps.version.outputs.value }}`
264+
- Release operation: `${{ steps.publish_release.outputs.operation }}`
265+
- Release URL: ${{ steps.publish_release.outputs.url }}

0 commit comments

Comments
 (0)