Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/actions/changelog/publish-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ inputs:
runs:
using: composite
steps:
- name: Publish release
- id: publish
name: Publish release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_NOTES_FILE: ${{ inputs.notes-file }}
run: ${{ github.action_path }}/run.sh

outputs:
operation:
description: Whether the release was created or updated.
value: ${{ steps.publish.outputs.operation }}
url:
description: URL of the published GitHub release.
value: ${{ steps.publish.outputs.url }}
7 changes: 7 additions & 0 deletions .github/actions/changelog/publish-release/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ set -euo pipefail
release_tag="v${INPUT_VERSION}"

if gh release view "${release_tag}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
operation="updated"
gh release edit "${release_tag}" \
--repo "${GITHUB_REPOSITORY}" \
--title "${release_tag}" \
--notes-file "${INPUT_NOTES_FILE}"
else
operation="created"
gh release create "${release_tag}" \
--repo "${GITHUB_REPOSITORY}" \
--target "${INPUT_TARGET}" \
--title "${release_tag}" \
--notes-file "${INPUT_NOTES_FILE}"
fi

release_url="$(gh release view "${release_tag}" --repo "${GITHUB_REPOSITORY}" --json url --jq '.url')"

echo "operation=${operation}" >> "${GITHUB_OUTPUT}"
echo "url=${release_url}" >> "${GITHUB_OUTPUT}"
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ inputs:
runs:
using: composite
steps:
- name: Cleanup orphaned previews
- id: cleanup
name: Cleanup orphaned previews
shell: bash
env:
INPUT_PATH: ${{ inputs.path }}
GH_TOKEN: ${{ github.token }}
run: ${{ github.action_path }}/run.sh

outputs:
deleted:
description: Number of deleted preview directories.
value: ${{ steps.cleanup.outputs.deleted }}
skipped:
description: Number of retained preview directories.
value: ${{ steps.cleanup.outputs.skipped }}
unresolved:
description: Number of unresolved preview directories.
value: ${{ steps.cleanup.outputs.unresolved }}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ done < <(find previews -mindepth 1 -maxdepth 1 -type d -name 'pr-*' | sort)

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

echo "deleted=${deleted}" >> "${GITHUB_OUTPUT}"
echo "skipped=${skipped}" >> "${GITHUB_OUTPUT}"
echo "unresolved=${unresolved}" >> "${GITHUB_OUTPUT}"

touch .nojekyll
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/summary/write/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Write Workflow Step Summary
description: Append deterministic Markdown to GITHUB_STEP_SUMMARY when content is available.

inputs:
markdown:
description: Markdown content to append to the workflow step summary.
required: true

runs:
using: composite
steps:
- name: Append summary
shell: bash
env:
INPUT_MARKDOWN: ${{ inputs.markdown }}
run: ${{ github.action_path }}/run.sh
8 changes: 8 additions & 0 deletions .github/actions/summary/write/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

if [ -z "${INPUT_MARKDOWN}" ]; then
exit 0
fi

printf '%s\n' "${INPUT_MARKDOWN}" >> "${GITHUB_STEP_SUMMARY}"
14 changes: 13 additions & 1 deletion .github/actions/wiki/cleanup-orphaned-previews/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ description: Delete wiki preview branches for pull requests that are no longer o
runs:
using: composite
steps:
- name: Cleanup orphaned previews
- id: cleanup
name: Cleanup orphaned previews
shell: bash
env:
GH_TOKEN: ${{ github.token }}
working-directory: .github/wiki
run: ${{ github.action_path }}/run.sh

outputs:
deleted:
description: Number of deleted preview branches.
value: ${{ steps.cleanup.outputs.deleted }}
skipped:
description: Number of retained preview branches.
value: ${{ steps.cleanup.outputs.skipped }}
unresolved:
description: Number of unresolved preview branches.
value: ${{ steps.cleanup.outputs.unresolved }}
16 changes: 14 additions & 2 deletions .github/actions/wiki/cleanup-orphaned-previews/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ set -euo pipefail

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

git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-* | while read -r remote_branch; do
deleted=0
skipped=0
unresolved=0

while read -r remote_branch; do
branch="${remote_branch#origin/}"
pull_request_number="${branch#pr-}"

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

Expand All @@ -18,12 +23,19 @@ git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-* | while re
CLOSED|MERGED)
echo "Deleting wiki preview branch ${branch} for ${state} pull request #${pull_request_number}."
git push origin --delete "${branch}" || true
deleted=$((deleted + 1))
;;
OPEN)
echo "Keeping wiki preview branch ${branch} for open pull request #${pull_request_number}."
skipped=$((skipped + 1))
;;
*)
echo "Could not resolve pull request #${pull_request_number} for wiki preview branch ${branch}. Keeping it."
unresolved=$((unresolved + 1))
;;
esac
done
done < <(git for-each-ref --format='%(refname:short)' refs/remotes/origin/pr-*)

echo "deleted=${deleted}" >> "${GITHUB_OUTPUT}"
echo "skipped=${skipped}" >> "${GITHUB_OUTPUT}"
echo "unresolved=${unresolved}" >> "${GITHUB_OUTPUT}"
2 changes: 1 addition & 1 deletion .github/wiki
Submodule wiki updated from e4312a to 2a1fdf
35 changes: 30 additions & 5 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ jobs:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: composer dev-tools changelog:check -- --file="${CHANGELOG_FILE}" --against="origin/${BASE_REF}"

- uses: ./.github/actions/summary/write
with:
markdown: |
## Changelog Validation Summary

- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Compared base ref: `origin/${{ github.event.pull_request.base.ref }}`
- Validation result: success

prepare_release_pull_request:
name: Prepare Release Pull Request
needs: resolve_php
Expand Down Expand Up @@ -181,11 +190,16 @@ jobs:
from-status: Merged
to-status: Release Prepared

- name: Summarize prepared release
run: |
echo "Prepared release version: ${{ steps.version.outputs.value }}"
echo "Pull request operation: ${{ steps.create_pr.outputs.pull-request-operation || 'none' }}"
echo "Pull request URL: ${{ steps.create_pr.outputs.pull-request-url || 'not created' }}"
- uses: ./.github/actions/summary/write
with:
markdown: |
## Release Preparation Summary

- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Release version: `${{ steps.version.outputs.value }}`
- Version source: `${{ steps.version.outputs.source }}`
- Pull request operation: `${{ steps.create_pr.outputs.pull-request-operation || 'none' }}`
- Pull request URL: ${{ steps.create_pr.outputs.pull-request-url || 'not created' }}

publish_merged_release:
name: Publish Merged Release
Expand Down Expand Up @@ -225,6 +239,7 @@ jobs:
version: ${{ steps.version.outputs.value }}

- name: Publish GitHub release
id: publish_release
uses: ./.github/actions/changelog/publish-release
with:
version: ${{ steps.version.outputs.value }}
Expand All @@ -238,3 +253,13 @@ jobs:
from-status: Release Prepared
to-status: Released
include-current-pull-request: 'true'

- uses: ./.github/actions/summary/write
with:
markdown: |
## Release Publication Summary

- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Published tag: `v${{ steps.version.outputs.value }}`
- Release operation: `${{ steps.publish_release.outputs.operation }}`
- Release URL: ${{ steps.publish_release.outputs.url }}
66 changes: 66 additions & 0 deletions .github/workflows/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ jobs:
permissions:
contents: write
pull-requests: read
outputs:
deleted: ${{ steps.cleanup.outputs.deleted }}
skipped: ${{ steps.cleanup.outputs.skipped }}
unresolved: ${{ steps.cleanup.outputs.unresolved }}

steps:
- uses: actions/checkout@v6
Expand All @@ -230,10 +234,72 @@ jobs:
path: gh-pages

- uses: ./.github/actions/github-pages/cleanup-orphaned-previews
id: cleanup
with:
path: gh-pages

- name: Push changes
run: |
cd gh-pages
git push

summarize:
if: ${{ always() }}
name: Summarize Reports Workflow
needs:
- resolve_php
- reports
- verify_main_reports
- verify_preview_reports
- cleanup_preview
- cleanup_orphaned_previews
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- id: build_summary
env:
TRIGGER_LABEL: ${{ github.event_name }}${{ github.event.action && format(':{0}', github.event.action) || '' }}
run: |
{
echo 'markdown<<EOF'
echo '## Reports Workflow Summary'
echo
echo "- Workflow PHP version: \`${{ needs.resolve_php.outputs.php-version }}\`"
echo "- PHP version source: \`${{ needs.resolve_php.outputs.php-version-source }}\`"
echo "- Reports job result: \`${{ needs.reports.result }}\`"
echo "- Main verification result: \`${{ needs.verify_main_reports.result }}\`"
echo "- Preview verification result: \`${{ needs.verify_preview_reports.result }}\`"
echo "- Closed-preview cleanup result: \`${{ needs.cleanup_preview.result }}\`"
echo "- Orphan cleanup result: \`${{ needs.cleanup_orphaned_previews.result }}\`"
echo "- Trigger: \`${TRIGGER_LABEL}\`"

if [ "${{ github.event_name }}" = "push" ] || { [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.cleanup-previews }}" != "true" ]; }; then
echo "- Docs: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
echo "- Coverage: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/coverage/"
echo "- Metrics: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/metrics/"
echo "- Deployment verification: \`${{ needs.verify_main_reports.result }}\`"
fi

if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" != "closed" ]; then
echo "- Preview docs: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/"
echo "- Preview coverage: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/coverage/"
echo "- Preview metrics: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/metrics/"
echo "- Preview verification: \`${{ needs.verify_preview_reports.result }}\`"
fi

if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "closed" ]; then
echo "- Deleted preview path: \`previews/pr-${{ github.event.pull_request.number }}\`"
echo "- Cleanup result: \`${{ needs.cleanup_preview.result }}\`"
fi

if [ "${{ github.event_name }}" = "schedule" ] || { [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.cleanup-previews }}" = "true" ]; }; then
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' }}"
fi

echo 'EOF'
} >> "$GITHUB_OUTPUT"

- uses: ./.github/actions/summary/write
with:
markdown: ${{ steps.build_summary.outputs.markdown }}
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,27 @@ jobs:
env:
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || -1 }}

summarize:
if: ${{ always() }}
name: Summarize Test Workflow
needs:
- resolve_php
- tests
- dependency-health
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: ./.github/actions/summary/write
with:
markdown: |
## Tests Workflow Summary

- Workflow PHP version: `${{ needs.resolve_php.outputs.php-version }}`
- PHP version source: `${{ needs.resolve_php.outputs.php-version-source }}`
- Test matrix: `${{ needs.resolve_php.outputs.test-matrix }}`
- Minimum coverage threshold: `${{ inputs.min-coverage || 80 }}`
- Dependency health `max-outdated`: `${{ inputs.max-outdated || -1 }}`
- Tests job result: `${{ needs.tests.result }}`
- Dependency health result: `${{ needs.dependency-health.result }}`
29 changes: 29 additions & 0 deletions .github/workflows/wiki-maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ jobs:
with:
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}

- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Publish Summary

- Publish branch: `${{ env.WIKI_PUBLISH_BRANCH }}`
- Preview branch: `${{ env.WIKI_PREVIEW_BRANCH }}`
- Expected preview SHA: `${{ steps.prepare_publish.outputs.expected-preview-sha }}`
- Publish validation: completed
- Preview cleanup: `${{ env.WIKI_PREVIEW_BRANCH }}` deleted

cleanup_closed_preview:
name: Delete Closed PR Wiki Preview
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == false
Expand Down Expand Up @@ -86,6 +97,14 @@ jobs:
with:
preview-branch: ${{ env.WIKI_PREVIEW_BRANCH }}

- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Preview Cleanup Summary

- Deleted preview branch: `${{ env.WIKI_PREVIEW_BRANCH }}`
- Trigger: closed pull request without merge

cleanup_orphaned_previews:
name: Delete Orphaned Wiki Previews
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
Expand All @@ -107,4 +126,14 @@ jobs:
run: git config --global --add safe.directory "$GITHUB_WORKSPACE/.github/wiki"

- name: Delete wiki branches for closed pull requests
id: cleanup
uses: ./.github/actions/wiki/cleanup-orphaned-previews

- uses: ./.github/actions/summary/write
with:
markdown: |
## Wiki Orphan Cleanup Summary

- Deleted preview branches: `${{ steps.cleanup.outputs.deleted || '0' }}`
- Retained preview branches: `${{ steps.cleanup.outputs.skipped || '0' }}`
- Unresolved preview branches: `${{ steps.cleanup.outputs.unresolved || '0' }}`
Loading
Loading