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
48 changes: 48 additions & 0 deletions .github/workflows/docs-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Check Docs"

on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"

jobs:
checkdocs:
name: "Check Docs"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
with:
coverage: none
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1, opcache.enable_cli=1

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}

- name: "extract php code"
run: "bin/docs-extract-php-code"

- name: "lint php"
run: "php -l docs_php/*.php"

- name: "docs code style"
run: "vendor/bin/phpcbf docs_php --exclude=SlevomatCodingStandard.TypeHints.DeclareStrictTypes,SlevomatCodingStandard.ControlStructures.EarlyExit"
71 changes: 71 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish docs

on:
push:
branches:
- "[0-9]+.[0-9]+.x"
paths:
- "docs/**"
release:
types:
- published

permissions:
contents: read

jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Check whether this ref belongs to the latest release of its major version
id: check
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
if [ "$EVENT_NAME" = "release" ]; then
current="$RELEASE_TAG"
else
current="$REF_NAME"
fi

major="${current%%.*}"

latest_tag=$(gh release list \
--repo "$GITHUB_REPOSITORY" \
--exclude-drafts \
--exclude-pre-releases \
--limit 1000 \
--json tagName \
--jq '.[].tagName' \
| grep -E "^${major}\.[0-9]+\.[0-9]+$" \
| sort -V \
| tail -n1)
latest_branch="${latest_tag%.*}.x"

if [ "$EVENT_NAME" = "release" ]; then
expected="$latest_tag"
else
expected="$latest_branch"
fi

echo "latest release of ${major}.x: ${latest_tag:-none} (branch ${latest_branch}), current: ${current}"

if [ -n "$latest_tag" ] && [ "$current" = "$expected" ]; then
echo "deploy=true" >> "$GITHUB_OUTPUT"
else
echo "deploy=false" >> "$GITHUB_OUTPUT"
echo "Skipping docs deployment: ${current} is not the latest release of ${major}.x."
fi

- name: Trigger workflow in other repo
if: steps.check.outputs.deploy == 'true'
run: |
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/patchlevel/patchlevel.dev/actions/workflows/prod-deployment.yaml/dispatches \
-d '{"ref":"main"}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ phpstan.neon
infection.log
infection.html
.phpbench/
docs_php/
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,27 @@ benchmark-diff-test: vendor
vendor/bin/phpbench run tests/Benchmark --revs=1 --report=diff --progress=none --ref=base


.PHONY: docs
docs: docs-extract-php docs-php-lint docs-phpcs docs-inject-php ## check and format docs code

.PHONY: docs-extract-php
docs-extract-php: vendor
bin/docs-extract-php-code

.PHONY: docs-inject-php
docs-inject-php: vendor
bin/docs-inject-php-code

.PHONY: docs-format
docs-format: docs-phpcs docs-inject-php ## format docs

.PHONY: docs-php-lint
docs-php-lint: docs-extract-php ## lint docs code
php -l docs_php/*.php | grep -E 'Parse error|Fatal error' || true

.PHONY: docs-phpcs
docs-phpcs: docs-extract-php
vendor/bin/phpcbf docs_php --exclude=SlevomatCodingStandard.TypeHints.DeclareStrictTypes,SlevomatCodingStandard.ControlStructures.EarlyExit || true

.PHONY: dev
dev: static test ## run dev tools
Loading
Loading