Update wiki.yml #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Wiki | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| wiki: | |
| name: Update Wiki | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: '${{ github.token }}' | |
| submodules: recursive | |
| - name: Get Composer Cache Directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| uses: php-actions/composer@v6 | |
| env: | |
| COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }' | |
| with: | |
| php_version: '8.4' | |
| - name: Create Docs Markdown | |
| uses: php-actions/composer@v6 | |
| with: | |
| php_version: '8.4' | |
| command: 'docs' | |
| - name: Commit & push changes in wiki submodule | |
| id: wiki_commit | |
| working-directory: docs/wiki | |
| run: | | |
| echo "Status before commit (submodule docs/wiki):" | |
| git status --porcelain || true | |
| changed="false" | |
| if [ -z "$(git status --porcelain)" ]; then | |
| echo "wiki_changed=$changed" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| default_branch="$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')" | |
| if [ -z "$default_branch" ]; then | |
| default_branch="main" | |
| fi | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "wiki_changed=$changed" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git commit -m "Update wiki docs at $(date "+%Y-%m-%d %H:%M:%S")" | |
| git push origin "$default_branch" | |
| changed="true" | |
| echo "wiki_changed=$changed" >> "$GITHUB_OUTPUT" | |
| - name: Update submodules | |
| id: update | |
| run: git submodule update --remote --recursive | |
| - name: Check if parent repo has submodule pointer changes | |
| id: changes | |
| if: steps.wiki_commit.outputs.wiki_changed == 'true' | |
| run: | | |
| git status --porcelain | |
| echo "wiki_changed='${{ steps.wiki_commit.outputs.wiki_changed }}'" | |
| git add docs/wiki | |
| changed="false" | |
| if ! git diff --cached --quiet; then | |
| changed="true" | |
| fi | |
| echo "changed=$changed" >> "$GITHUB_OUTPUT" | |
| - name: Add and commit parent repo | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| git commit -m "Update wiki submodule pointer at $(date "+%Y-%m-%d %H:%M:%S")" | |
| - name: Push changes (parent repo) | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ github.token }} | |
| branch: ${{ github.ref_name }} |