Skip to content

Commit 44e2bd3

Browse files
committed
[github-actions] Build reports summary markdown safely (#148)
1 parent 5192fdf commit 44e2bd3

1 file changed

Lines changed: 44 additions & 15 deletions

File tree

.github/workflows/reports.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,20 +257,49 @@ jobs:
257257
steps:
258258
- uses: actions/checkout@v6
259259

260+
- id: build_summary
261+
env:
262+
TRIGGER_LABEL: ${{ github.event_name }}${{ github.event.action && format(':{0}', github.event.action) || '' }}
263+
run: |
264+
{
265+
echo 'markdown<<EOF'
266+
echo '## Reports Workflow Summary'
267+
echo
268+
echo "- Workflow PHP version: \`${{ needs.resolve_php.outputs.php-version }}\`"
269+
echo "- PHP version source: \`${{ needs.resolve_php.outputs.php-version-source }}\`"
270+
echo "- Reports job result: \`${{ needs.reports.result }}\`"
271+
echo "- Main verification result: \`${{ needs.verify_main_reports.result }}\`"
272+
echo "- Preview verification result: \`${{ needs.verify_preview_reports.result }}\`"
273+
echo "- Closed-preview cleanup result: \`${{ needs.cleanup_preview.result }}\`"
274+
echo "- Orphan cleanup result: \`${{ needs.cleanup_orphaned_previews.result }}\`"
275+
echo "- Trigger: \`${TRIGGER_LABEL}\`"
276+
277+
if [ "${{ github.event_name }}" = "push" ] || { [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.cleanup-previews }}" != "true" ]; }; then
278+
echo "- Docs: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
279+
echo "- Coverage: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/coverage/"
280+
echo "- Metrics: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/metrics/"
281+
echo "- Deployment verification: \`${{ needs.verify_main_reports.result }}\`"
282+
fi
283+
284+
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" != "closed" ]; then
285+
echo "- Preview docs: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/"
286+
echo "- Preview coverage: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/coverage/"
287+
echo "- Preview metrics: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/metrics/"
288+
echo "- Preview verification: \`${{ needs.verify_preview_reports.result }}\`"
289+
fi
290+
291+
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "closed" ]; then
292+
echo "- Deleted preview path: \`previews/pr-${{ github.event.pull_request.number }}\`"
293+
echo "- Cleanup result: \`${{ needs.cleanup_preview.result }}\`"
294+
fi
295+
296+
if [ "${{ github.event_name }}" = "schedule" ] || { [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.cleanup-previews }}" = "true" ]; }; then
297+
echo "- Cleanup summary: deleted=${{ needs.cleanup_orphaned_previews.outputs.deleted || '0' }}, skipped=${{ needs.cleanup_orphaned_previews.outputs.skipped || '0' }}, unresolved=${{ needs.cleanup_orphaned_previews.outputs.unresolved || '0' }}"
298+
fi
299+
300+
echo 'EOF'
301+
} >> "$GITHUB_OUTPUT"
302+
260303
- uses: ./.github/actions/summary/write
261304
with:
262-
markdown: |
263-
## Reports Workflow Summary
264-
265-
- Workflow PHP version: `${{ needs.resolve_php.outputs.php-version }}`
266-
- PHP version source: `${{ needs.resolve_php.outputs.php-version-source }}`
267-
- Reports job result: `${{ needs.reports.result }}`
268-
- Main verification result: `${{ needs.verify_main_reports.result }}`
269-
- Preview verification result: `${{ needs.verify_preview_reports.result }}`
270-
- Closed-preview cleanup result: `${{ needs.cleanup_preview.result }}`
271-
- Orphan cleanup result: `${{ needs.cleanup_orphaned_previews.result }}`
272-
- Trigger: `${{ github.event_name }}${{ github.event.action && format(':{0}', github.event.action) || '' }}`
273-
${{ (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.cleanup-previews)) && format('- Docs: https://{0}.github.io/{1}/\n- Coverage: https://{0}.github.io/{1}/coverage/\n- Metrics: https://{0}.github.io/{1}/metrics/\n- Deployment verification: `{2}`', github.repository_owner, github.event.repository.name, needs.verify_main_reports.result) || '' }}
274-
${{ (github.event_name == 'pull_request' && github.event.action != 'closed') && format('- Preview docs: https://{0}.github.io/{1}/previews/pr-{2}/\n- Preview coverage: https://{0}.github.io/{1}/previews/pr-{2}/coverage/\n- Preview metrics: https://{0}.github.io/{1}/previews/pr-{2}/metrics/\n- Preview verification: `{3}`', github.repository_owner, github.event.repository.name, github.event.pull_request.number, needs.verify_preview_reports.result) || '' }}
275-
${{ (github.event_name == 'pull_request' && github.event.action == 'closed') && format('- Deleted preview path: `previews/pr-{0}`\n- Cleanup result: `{1}`', github.event.pull_request.number, needs.cleanup_preview.result) || '' }}
276-
${{ ((github.event_name == 'schedule') || (github.event_name == 'workflow_dispatch' && inputs.cleanup-previews)) && format('- Cleanup summary: deleted={0}, skipped={1}, unresolved={2}', needs.cleanup_orphaned_previews.outputs.deleted || '0', needs.cleanup_orphaned_previews.outputs.skipped || '0', needs.cleanup_orphaned_previews.outputs.unresolved || '0') || '' }}
305+
markdown: ${{ steps.build_summary.outputs.markdown }}

0 commit comments

Comments
 (0)