Skip to content

Commit

Permalink
Add reusable build action
Browse files Browse the repository at this point in the history
Adds a new `reusable.yml` GitHub Actions workflow, that can be reused
by the `doc-base` repo and individual `php/doc-*` repos.

The new reusable workflow accepts inputs that control the repos it
checks out, the name of the language, and other tasks that the
`integration.yaml` file previously did.

The new `build.yml` file then uses the `reusable.yml` workflow by
passing parameters to run the same list of existing language builds.

The advantage of this is that `doc-base` acts as the baseline GitHub
Actions repo, and updates to it (such as changing the `runs-on` value,
updating `uses` values for other actions such as `actions/checkout`,
and other chores only need to be done on the `doc-base`, and not on
every `php/doc-*` repo.

Individual `php/doc-*` repos need to be updated to make use of the new
reusable workflows, e.g.:

```yml
name: "Build Ukrainian language documentation"

on:
  push:
  pull_request:
    branches: "master"
  workflow_dispatch:

jobs:
  build:
    uses: php/doc-base/.github/workflows/reusable.yml@master
    with:
      language: 'uk'
```
  • Loading branch information
Ayesh committed Mar 3, 2025
1 parent bd3c7d6 commit 68d7858
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 62 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://docs.github.com/en/actions

name: "Integrate"

on:
pull_request: null
push:

jobs:
build:
name: "Build: ${{ matrix.language }}"
strategy:
matrix:
language:
- "de"
- "en"
- "es"
- "fr"
- "it"
- "ja"
- "pl"
- "pt_br"
# - "ro"
- "ru"
- "tr"
- "uk"
- "zh"

uses: "./.github/workflows/reusable.yml"
with:
repo: 'php/doc-${{ matrix.language }}'
repo_ref: ''
language: ${{ matrix.language }}
62 changes: 0 additions & 62 deletions .github/workflows/integrate.yaml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Reusable GitHub Action to build the documentation for a given repository.

name: "Build"

on:
workflow_call:
inputs:
language:
required: true
type: string
description: "Language code (e.g. de, it, es, etc) indicating the language of the documentation."
repo:
required: false
type: string
default: ${{ github.repository }}
description: "Repo path (e.g. php/doc-de) to build the documentation from."
repo_ref:
required: false
type: string
default: ${{ github.ref }}
description: "Repository checkout ref, defaults ref that triggered the action (github.ref)."
doc_base:
required: false
type: string
default: 'php/doc-base'
description: "Repo path to the doc-base repository, defaults to php/doc-base."
doc_en:
required: false
type: string
default: 'php/doc-en'
description: "Repo path to the doc-en repository, defaults to php/doc-en."

jobs:
build:
name: "Build - ${{ inputs.language }} - ${{ inputs.repo }}"
runs-on: ubuntu-latest
steps:
- name: "Checkout doc-base"
uses: "actions/checkout@v4"
with:
path: "doc-base"
repository: ${{ inputs.doc_base }}

- name: "Checkout ${{ inputs.language }} from ${{ inputs.repo }}"
uses: "actions/checkout@v4"
with:
path: ${{ inputs.language }}
repository: ${{ inputs.repo }}
ref: ${{ inputs.repo_ref }}

- name: "Checkout ${{ inputs.doc_en }} as fallback"
if: "${{ inputs.language }} != 'en'"
uses: "actions/checkout@v4"
with:
path: "en"
repository: ${{ inputs.doc_en }}

- name: "Run QA scripts for EN docs"
if: "${{ inputs.language }} == 'en'"
run: |
php doc-base/scripts/qa/extensions.xml.php --check
php doc-base/scripts/qa/section-order.php
- name: "Build documentation for ${{ inputs.language }}"
run: "php doc-base/configure.php --disable-libxml-check --enable-xml-details --redirect-stderr-to-stdout --with-lang=${{ inputs.language }}"

0 comments on commit 68d7858

Please sign in to comment.