Skip to content
Discussion options

You must be logged in to vote

When a workflow runs as a reusable workflow the context is not the same as a normal event run so checking github.event_name == 'workflow_call' inside the called workflow does not work as you expect. The clean way is to pass the event type down as an input when you call the reusable workflow and then check that input inside.
Example caller workflow
jobs:
call-build:
uses: ./.github/workflows/reusable.yml
with:
caller_event: ${{ github.event_name }}
Example reusable workflow
on:
workflow_call:
inputs:
caller_event:
required: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: upload artifact only when called
if: ${{ inputs.caller_event == 'workflow_call' }}
uses: actions/upload-artifac…

Replies: 1 comment 1 reply

This comment was marked as off-topic.

@higaski
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question Ask and answer questions about GitHub features and usage Misc General discussions about GitHub Actions that don't fit other found themes.
1 participant