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
75 changes: 64 additions & 11 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
generate-api-data:
if: "!contains(github.event.head_commit.message, 'Update autogenerated JSON files')"
runs-on: ubuntu-latest
# Permissions needed to create PR and write content
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout code
Expand All @@ -39,28 +43,75 @@ jobs:
run: |
npm run generate-json-api

- name: Commit and push if there are any changes
working-directory: ./projects/composition
run: |
git config user.name github-actions
git config user.email [email protected]
git pull origin master
git add ./src/app/api-data
if [[ -n "$(git status --porcelain)" ]]; then
git commit -m "Update autogenerated JSON files"
git push origin HEAD:master
fi
# Instead of direct commit/push, create a PR
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
# More descriptive commit message
commit-message: 'chore: Update API documentation JSON files'
# Use bot account for better tracking
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Unique branch name using run number to avoid conflicts
branch: api-docs-update-${{ github.run_number }}
# Auto-delete branch after merge
delete-branch: true
title: 'chore: Update API documentation JSON files'
# Detailed PR description with context
body: |
## Auto-generated API Documentation Update

This PR contains automatically generated API documentation files.

### Changes
- Updated JSON API files based on latest component changes

### Workflow Run
- Triggered by commit: ${{ github.sha }}
- Run ID: ${{ github.run_id }}

---

🤖 This PR was automatically created by the documentation workflow.
# Labels for organization and to skip changelog
labels: |
documentation
automated
skip-changelog

# Auto-merge the PR (requires repo settings to allow auto-merge)
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash

# Auto-approve the PR so it can be merged
- name: Auto approve PR
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}

# Build job
build:
runs-on: ubuntu-latest
needs: generate-api-data
# Only run if generate-api-data succeeded or was skipped (not failed)
if: always() && (needs.generate-api-data.result == 'success' || needs.generate-api-data.result == 'skipped')

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
# Explicitly checkout master to get latest changes after PR merge
ref: master

- name: Fetch latest commits
run: git pull origin master
Expand Down Expand Up @@ -104,6 +155,8 @@ jobs:
# Deploy job
deploy:
needs: build
# Only deploy if build succeeded
if: success()

permissions:
pages: write
Expand Down
Loading
Loading