Skip to content

Seemingly wrong limitation on GitHub Actions reusable workflow and composite action #23572

@micnncim

Description

@micnncim

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/using-workflows/reusing-workflows

What part(s) of the article would you like to see updated?

https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations

You cannot use a reusable workflow from another repository if it uses a composite action. For more information, see "About custom actions."

That said, turns out it's possible to do - below are the details of testing:

Composite action:

# .github/actions/test/action.yml
name: Test

on:
  workflow_call:
    inputs:
      foo:
        type: string
        description: Foo
        required: true

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Check out
        uses: actions/checkout@v3

      - name: Echo
        run: echo "Hello from reusable workflow! inputs.foo=${{ inputs.foo }}"

      - name: Run composite action
        uses: micnncim/test-gha-composite-action/.github/actions/test@main
        with:
          foo: ${{ inputs.foo }}

Reusable workflow:

# .github/workflows/_test.yml
name: Test

on:
  workflow_call:
    inputs:
      foo:
        type: string
        description: Foo
        required: true

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Check out
        uses: actions/checkout@v3

      - name: Echo
        run: echo "Hello from reusable workflow! inputs.foo=${{ inputs.foo }}"

      - name: Run composite action
        uses: micnncim/test-gha-composite-action/.github/actions/test@main
        with:
          foo: ${{ inputs.foo }}

Workflow using the reusable workflow:

# .github/workflows/test.yml
name: Test

on:
  workflow_dispatch:
    inputs:
      foo:
        description: Foo
        required: true

jobs:
  test:
    uses: micnncim/test-gha-composite-action/.github/workflows/_test.yml@main
    with:
      foo: ${{ github.event.inputs.foo }}

Workflow run result:

Screen Shot 2023-01-30 at 14 28 12

The repositories used for the testing are available on micnncim/test-gha-composite-action and micnncim/test-gha-reusable-workflow.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions