Use repoplone in GitHub Actions#

This guide shows you how to feed a GitHub Actions workflow from repository.toml. One job reads the settings. The jobs after it build only the components that changed.

Read the settings in a first job#

repoplone settings github-outputs prints step outputs in the format $GITHUB_OUTPUT expects. Append them to that file in a job of its own, and expose the ones the other jobs need.

jobs:
  config:
    runs-on: ubuntu-latest
    outputs:
      components: ${{ steps.settings.outputs.components }}
      image-name-prefix: ${{ steps.settings.outputs.image-name-prefix }}
      backend-version: ${{ steps.settings.outputs.backend-version }}
      paths-filter: ${{ steps.settings.outputs.paths-filter }}
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install uv
        uses: astral-sh/setup-uv@v7

      - name: Read repository settings
        id: settings
        run: uvx repoplone@2.0.0a2 settings github-outputs >> "$GITHUB_OUTPUT"

For a repository with a backend, a volto, and an aurora component, the command prints these lines after components and packages. Those two are JSON lists, one entry per component and per package, described in GitHub Actions outputs.

image-name-prefix=ghcr.io/organization/fake-components
backend-version=6.2.3
volto-version=19.0.0-alpha.6
volto-volto-version=19.0.0-alpha.6
aurora-version=1.0.0-alpha.30
paths-filter<<REPOPLONE_PATHS_FILTER
backend:
  - 'backend/**'
  - 'packages/acme-videos/**'
volto:
  - 'volto/**'
  - 'packages/volto-videos/**'
  - 'packages/videos-core/**'
aurora:
  - 'aurora/**'
  - 'packages/aurora-videos/**'
  - 'packages/videos-core/**'
REPOPLONE_PATHS_FILTER

A repository without [[component]] tables gets the same outputs for its implicit backend and frontend components.

Find the components that changed#

The paths-filter output is a filter for dorny/paths-filter, with one entry per component. Each entry lists the component’s folder and the folders of its packages. A change to a package shared by two apps marks both apps as changed.

  changes:
    needs: config
    runs-on: ubuntu-latest
    outputs:
      components: ${{ steps.filter.outputs.changes }}
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Find changed components
        id: filter
        uses: dorny/paths-filter@v4
        with:
          filters: ${{ needs.config.outputs.paths-filter }}

The changes output of the filter step is a JSON list of the names of the components that changed, such as ["volto","aurora"].

Build one image per changed component#

Turn that list into a matrix. Each component also has an image name in the components output, made of the image name prefix and the component name.

  images:
    needs: [config, changes]
    if: ${{ needs.changes.outputs.components != '[]' }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        component: ${{ fromJSON(needs.changes.outputs.components) }}
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Build the image of ${{ matrix.component }}
        env:
          PREFIX: ${{ needs.config.outputs.image-name-prefix }}
          COMPONENT: ${{ matrix.component }}
        run: |
          docker build -t "${PREFIX}-${COMPONENT}" "${COMPONENT}"

The build command is only an example. Use the one your project’s images need. The component’s folder, its path in the components output, is often the build context.

Use the base package versions#

Each component gets a <name>-version output with the version of its base package. A Volto component also gets <name>-volto-version, the Volto core version, which differs from the base package version when the base package is a Volto distribution. Pass them as build arguments. The image is then built against the Plone or Volto version the repository pins.

      - name: Build the backend image
        env:
          PLONE_VERSION: ${{ needs.config.outputs.backend-version }}
        run: |
          docker build --build-arg PLONE_VERSION="${PLONE_VERSION}" -t backend backend

See also