From f9df1bacb29c8cdf34252af46d19a3488ffddc25 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Mon, 3 Mar 2025 21:04:45 +0700 Subject: [PATCH] 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' ``` --- .github/workflows/build-reusable.yml | 65 ++++++++++++++++++++++++++++ .github/workflows/build.yml | 33 ++++++++++++++ .github/workflows/integrate.yaml | 62 -------------------------- 3 files changed, 98 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/build-reusable.yml create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/integrate.yaml diff --git a/.github/workflows/build-reusable.yml b/.github/workflows/build-reusable.yml new file mode 100644 index 000000000..b75cd258a --- /dev/null +++ b/.github/workflows/build-reusable.yml @@ -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 }}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..b05ad0cc8 --- /dev/null +++ b/.github/workflows/build.yml @@ -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/build-reusable.yml" + with: + repo: 'php/doc-${{ matrix.language }}' + repo_ref: '' + language: ${{ matrix.language }} diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml deleted file mode 100644 index 042d11ece..000000000 --- a/.github/workflows/integrate.yaml +++ /dev/null @@ -1,62 +0,0 @@ -# https://docs.github.com/en/actions - -name: "Integrate" - -on: - pull_request: null - push: - branches: - - "master" - -jobs: - build: - name: "Build" - - runs-on: "ubuntu-latest" - - continue-on-error: true - - strategy: - matrix: - language: - - "de" - - "en" - - "es" - - "fr" - - "it" - - "ja" - - "pl" - - "pt_br" -# - "ro" - - "ru" - - "tr" - - "uk" - - "zh" - - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - path: "doc-base" - - - name: "Checkout php/doc-${{ matrix.language }}" - uses: "actions/checkout@v4" - with: - path: "${{ matrix.language }}" - repository: "php/doc-${{ matrix.language }}" - - - name: "Checkout php/doc-en as fallback" - if: "matrix.language != 'en'" - uses: "actions/checkout@v4" - with: - path: "en" - repository: "php/doc-en" - - - name: "Run QA scripts for EN docs" - if: "matrix.language == 'en'" - run: | - php doc-base/scripts/qa/extensions.xml.php --check - php doc-base/scripts/qa/section-order.php - - - name: "Build documentation for ${{ matrix.language }}" - run: "php doc-base/configure.php --disable-libxml-check --enable-xml-details --redirect-stderr-to-stdout --with-lang=${{ matrix.language }}"