0

I have a workflow which is calling a reusable workflow. This caller workflow is defined with

name: My CI Pipeline

on:
  push:
    branches: [ "master" ]

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

jobs:
  ...

When I push changes in my repository the Action Runner starts the workflow and this calls a reusable workflow (which, in turn, calls a further reusable workflow, ...). Fine! If another push into the repository takes place the starting workflow gets interrupted. Fine! The problem: The called reusable workflow continues to run.

Because I rely on a value stored in a repository variable during processing the first reusable workflow I may run into problems. Hence, how can I stop all called workflows when the concurrency feature takes place?

At the end of the main workflow I have

  run_build_wf:
    needs: check_changes
    if: needs.check_changes.outputs.changed_part_be == 'backend' || needs.check_changes.outputs.changed_part_fe == 'frontend'
    uses: ./.github/workflows/build_workflow.yml
    secrets: inherit
    with:
      changed_part_be: ${{needs.check_changes.outputs.changed_part_be}}
      changed_part_fe: ${{needs.check_changes.outputs.changed_part_fe}}

Do I have to put some concurrency stuff in the called workflow?

du-it
  • 2,561
  • 8
  • 42
  • 80

2 Answers2

0

Concurrency is also available on reusable workflows.

Please try this

jobs:
  checks:
    concurrency:
      group: ${{ github.ref }}
      cancel-in-progress: true
    uses: ./.github/workflows/unit_tests_and_linters.yaml
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • But this in job level not on workflow level. – du-it Sep 01 '23 at 12:59
  • This job calls reusable workflow, as this it is reusable workflow level. Here you have link to [documentation](https://docs.github.com/en/actions/using-workflows/reusing-workflows#supported-keywords-for-jobs-that-call-a-reusable-workflow) – Krzysztof Madej Sep 01 '23 at 13:14
0

Just putting

name: My called reusable workflow

on:
  workflow_call:

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

in each called (reusable) workflow seems to do the magic.

du-it
  • 2,561
  • 8
  • 42
  • 80