How to change concurrent (parallel) jobs number?

I have created a workflow, where I want it should run 1 at a time instead of running in parallel.

BTW, I am talking about these concurrent jobs

Not these
Screenshot 2020-09-13 at 7.45.17 PM

A workflow has jobs, a job has steps. You’re describing the concurrency of workflows, not jobs – minor distinction in language but important when thinking about the documentation and how you solve this problem.

GitHub Actions do not currently support managing workflow concurrency but there is an action called turnstyle which will block workflows, meaning that only one can run at a time. This is less than perfect as a solution (because you’ll be charged for the waiting job minutes) but it will allow for your use-case of enforcing a concurrency limit of 1 for workflows.

That said, if you do have a dependency between workflows, it is a sign that you may wish to reconsider whether multiple workflows is appropriate and if instead it should be dependent jobs (using needs).

Ah! Sorry for incorrect terminology. I wasn’t sure how to actually say it.

Anyway, using turnstyle might fulfil my use-case for now.

But as it will cost even if the other workflows are waiting in queue.

If GitHub Staff is watching this post, please consider adding the feature to defining how many concurrent workflow it can run.

Just a side note: it might also help who are using self-hosted runners while there server might not be able to handle multiple running workflows at the same time (for certain use-cases), but with parallel-workflows: 2 (something like this), it will put their servers at it ease (hope that make sense).

I did some further digging and you could use the new workflow_dispatch event to meet your needs without incurring additional minutes. Although not perfect because it will tightly couple each of your workflows, use benc-uk/workflow-dispatch@v1 to chain the workflows together.

Set your first workflow (e.g: Workflow A) to run on push, then as the final step in the final job of Workflow A you would publish a workflow_dispatch event for the next workflow which would be set to be triggered by workflow_dispatch instead of push. Repeat for each subsequent Workflow in the chain.

name: Workflow A

on: [push]

jobs:
  first-job:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Hello, World!"
      - uses: benc-uk/workflow-dispatch@v1
         with:
           workflow: Workflow B
           token: ${{ secrets.PERSONAL_TOKEN }}
name: Workflow B

on: [workflow_dispatch]

jobs:
  first-job:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Hello, World!"
      - uses: benc-uk/workflow-dispatch@v1
         with:
           workflow: Workflow C
           token: ${{ secrets.PERSONAL_TOKEN }}