Skip to content

IBX-9904: Workflow to build API refs into new PR #2723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
54 changes: 54 additions & 0 deletions .github/workflows/api_refs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Build API Refs'

on:
workflow_dispatch:
inputs:
version:
description: 'Released version'
required: true
type: string
Comment on lines +6 to +9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used to build the references, only to create the branch.

  • The script could evolve to receive version as an argument instead of alway building for the latest version (Is there a need for building old references?).
  • Or just rename the inputs being renamed to avoid ambiguity (my favorite).
Suggested change
version:
description: 'Released version'
required: true
type: string
branch_suffix:
description: "Used in branch name to open PR for the latest version's references"
required: true
type: string


jobs:
open_php_api_ref_pr:
name: "PHP & REST API References' PR"
runs-on: ubuntu-latest

steps:
- name: Set version and branches
id: version_and_branches
run: |
version="${{ inputs.version }}"
base_branch="$(echo $version | sed -s /v(.*\..*)\..*/\1/)"
work_branch="api_refs_$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "base_branch=$base_branch" >> "$GITHUB_OUTPUT"
echo "work_branch=$work_branch" >> "$GITHUB_OUTPUT"

- name: Checkout documentation
uses: actions/checkout@v4

- name: Build API Refs
# TODO: On 5.0, update tool to handle both PHP & REST APIs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do this, few lines can be added to the 5.0 version of phpdoc.sh:

$PHP_BINARY bin/console ibexa:openapi --yaml > openapi.yaml
redocly build-docs openapi.yaml --output $(realpath $OUTPUT_DIR/../../rest_api/rest_api_reference/rest_api_reference.html)

Anyway, the tool should be renamed and reworked to reflect its new task of building both references.

# TODO: Composer auth?
run: tools/php_api_ref/phpdoc.sh

- name: Commit and push
run: |
git checkout ${{ steps.version_and_branches.outputs.work_branch }}
git add docs/api/php_api/php_api_reference/ tools/php_api_ref/.phpdoc/template/package-edition-map.twig
#TODO: Set a user?
git commit -m "PHP API Ref HTML"
#TODO: git add doc/api/rest_api/rest_api_reference/rest_api_reference.html
#TODO: git commit -m "REST API Ref HTML"
#TODO: permission to push? Use an action? https://github.com/marketplace/actions/github-push
git push

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
#TODO: token: ${{ ? }}
title: "PHP API Ref ${{ steps.version_and_branches.outputs.version }}"
body: "PHP API Reference update for ${{ steps.version_and_branches.outputs.version }}"
branch: "${{ steps.version_and_branches.outputs.work_branch }}"
base: "${{ steps.version_and_branches.outputs.base_branch }}"
draft: false