Bug in IF conditions on inputs for reusable workflows
See original GitHub issueProblem:
When a reusable workflow (called workflow), contains if conditions (based on the input of the job) at job level, there is a observation that the if condition seems to execute and use value globally (causing jobs which are being skipped because of a check).
Example
Caller workflow: Simple workflow calling a reusable workflow passing in the github event (PR or push) to the reusable workflow
name: caller-workflow
on:
pull_request:
push:
branches:
- master
# 2
jobs:
call-the-workflow:
uses: action-foobar/action-testing/.github/workflows/called_workflow.yml@master
with:
TRIGGER_EVENT : ${{ github.event_name }}
Reusable workflow: Workflow with a sequence of job which has conditions based on the input (whether it is a pull_request or a push)
name: tf-app-dns-reusable
on:
workflow_call:
inputs:
TRIGGER_EVENT:
description: trigger event for the workflow
required: true
type: string
jobs:
lint:
runs-on: ubuntu-latest
name: Validate terraform configuration
steps:
- name: Checkout
uses: actions/checkout@v2
- name: debug
run: |
echo ${{ inputs.TRIGGER_EVENT }}
plan-non-prod:
if: ${{ inputs.TRIGGER_EVENT == 'pull_request' }}
needs: lint
runs-on: ubuntu-latest
name: Plan Application DNS Non Prod
steps:
- name: debug
run: |
echo "triggered event"
echo ${{ inputs.TRIGGER_EVENT }}
plan-prod:
if: ${{ inputs.TRIGGER_EVENT == 'pull_request' }}
needs: "plan-non-prod"
runs-on: ubuntu-latest
name: Plan Application DNS Prod
steps:
- name: debug
run: |
echo "triggered event"
echo ${{ inputs.TRIGGER_EVENT }}
apply-non-prod:
if: ${{ inputs.TRIGGER_EVENT == 'push' }}
needs: lint
runs-on: ubuntu-latest
name: apply non prod
steps:
- name: debug
run: |
echo "triggered event"
echo ${{ inputs.TRIGGER_EVENT }}
Observation
-
Job 3 gets the check skipped , even though the condition is valid and matches as Job 2 (Job 3 only depends on success of job 2 and the same
IF
condition as job2. -
On removal of the
IF
condition on Job 4 , then Job 3 executes fine .
Which implies of some sort of “state” of the IF condition (since there is no relationship between Job 4 and Job 3).
The observation of runs can be found in this repository here -> https://github.com/action-foobar/action-testing/actions/runs/1682109402
PS:
This was working perfectly fine till 11PM GMT 10th Jan . (as we have a lot of jobs in our org on this setup)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:24
- Comments:21
Top GitHub Comments
The root cause was a server side change we cannot quickly revert at this time, we are working on a fix that should rollout to all users over the next day or two.
Thank you everyone for your patience as we address this issue. This issue will be updated when the bug is fixed and rolled out to everyone.
👋 Hi folks, I’m sorry about this disruption.
The fix should finish rolling out in the next ~20 minutes. After that, all new runs going forward should work correctly.
Again, I’m sorry about the disruption. We’ll review this, and we’ll do better going forward.