Reputation: 7764
I have the following workflow:
name: CICD
# ...
jobs:
CI:
uses: ...
CD:
needs: [CI]
uses: ...
I have encountered an issue that needs me to temporally disable the CD job that uses other workflows (not just a single step or action).
There seems to be a recent update about "Skipping workflow runs"
You can skip workflow runs triggered by the push and pull_request events by including a command in your commit message.
This sounds inconvenient, at the bottom they mention:
You can also disable a workflow from running. For more information, see "Disabling and enabling a workflow."
In which you can disable and re-enable a workflow using the GitHub UI, the REST API, or GitHub CLI. However, this doesn't seem to work for when the workflow is being used as a reusable workflows.
I can also simply omit the logic:
name: CICD
# ...
jobs:
CI:
uses: ...
But I want to preserve the version control history differently (+ make my pipeline explicitly state the job was disabled / skipped)
Is there a workaround?
Upvotes: 35
Views: 20867
Reputation: 7764
Yes, you can use conditions to control job execution:
You can instead use the
jobs.<job_id>.if
conditional to prevent a job from running unless a condition is met.
So if you update your CD job workflow to an indefinite negative condition:
name: CICD
# ...
jobs:
CI:
uses: ...
CD:
if: false
needs: [CI]
uses: ...
It will cause the job to always be skipped (i.e. "disabled").
Upvotes: 53