Skip to content

Commit f9df1ba

Browse files
committed
Add reusable build action
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/build-reusable.yml@master with: language: 'uk' ```
1 parent bd3c7d6 commit f9df1ba

File tree

3 files changed

+98
-62
lines changed

3 files changed

+98
-62
lines changed

.github/workflows/build-reusable.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Reusable GitHub Action to build the documentation for a given repository.
2+
3+
name: "Build"
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
language:
9+
required: true
10+
type: string
11+
description: "Language code (e.g. de, it, es, etc) indicating the language of the documentation."
12+
repo:
13+
required: false
14+
type: string
15+
default: ${{ github.repository }}
16+
description: "Repo path (e.g. php/doc-de) to build the documentation from."
17+
repo_ref:
18+
required: false
19+
type: string
20+
default: ${{ github.ref }}
21+
description: "Repository checkout ref, defaults ref that triggered the action (github.ref)."
22+
doc_base:
23+
required: false
24+
type: string
25+
default: 'php/doc-base'
26+
description: "Repo path to the doc-base repository, defaults to php/doc-base."
27+
doc_en:
28+
required: false
29+
type: string
30+
default: 'php/doc-en'
31+
description: "Repo path to the doc-en repository, defaults to php/doc-en."
32+
33+
jobs:
34+
build:
35+
name: "Build - ${{ inputs.language }} - ${{ inputs.repo }}"
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: "Checkout doc-base"
39+
uses: "actions/checkout@v4"
40+
with:
41+
path: "doc-base"
42+
repository: ${{ inputs.doc_base }}
43+
44+
- name: "Checkout ${{ inputs.language }} from ${{ inputs.repo }}"
45+
uses: "actions/checkout@v4"
46+
with:
47+
path: ${{ inputs.language }}
48+
repository: ${{ inputs.repo }}
49+
ref: ${{ inputs.repo_ref }}
50+
51+
- name: "Checkout ${{ inputs.doc_en }} as fallback"
52+
if: "${{ inputs.language }} != 'en'"
53+
uses: "actions/checkout@v4"
54+
with:
55+
path: "en"
56+
repository: ${{ inputs.doc_en }}
57+
58+
- name: "Run QA scripts for EN docs"
59+
if: "${{ inputs.language }} == 'en'"
60+
run: |
61+
php doc-base/scripts/qa/extensions.xml.php --check
62+
php doc-base/scripts/qa/section-order.php
63+
64+
- name: "Build documentation for ${{ inputs.language }}"
65+
run: "php doc-base/configure.php --disable-libxml-check --enable-xml-details --redirect-stderr-to-stdout --with-lang=${{ inputs.language }}"

.github/workflows/build.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# https://docs.github.com/en/actions
2+
3+
name: "Integrate"
4+
5+
on:
6+
pull_request: null
7+
push:
8+
9+
jobs:
10+
build:
11+
name: "Build: ${{ matrix.language }}"
12+
strategy:
13+
matrix:
14+
language:
15+
- "de"
16+
- "en"
17+
- "es"
18+
- "fr"
19+
- "it"
20+
- "ja"
21+
- "pl"
22+
- "pt_br"
23+
# - "ro"
24+
- "ru"
25+
- "tr"
26+
- "uk"
27+
- "zh"
28+
29+
uses: "./.github/workflows/build-reusable.yml"
30+
with:
31+
repo: 'php/doc-${{ matrix.language }}'
32+
repo_ref: ''
33+
language: ${{ matrix.language }}

.github/workflows/integrate.yaml

-62
This file was deleted.

0 commit comments

Comments
 (0)