Skip to content

Github context not available in reusable workflows #2349

Closed

Description

@pantelis-karamolegkos

Filing this as a bug since the behaviour does not seem to adhere to the docs.

Describe the bug

According to the docs:

When a reusable workflow is triggered by a caller workflow, the github context is always associated with the caller workflow.

However, this does not seem to be the case.

To Reproduce
Steps to reproduce the behavior:

  1. Invoke a reusable workflow, passing the context as input.
  set-tag:
    name: set the build branch and image tag
    needs:
      - set-ref
    uses: MyOrg/my-repo/.github/workflows/reusable.yaml@master
    with:
      push_to_prd: ${{ inputs.push_to_prd }}
      tag: ${{ inputs.manual_version }}
      ref: ${{ needs.set-ref.outputs.ref }}
      event: ${{ github.event }}

Expected behavior
The event name (e.g. push) should be passed as input to the invoked / reusable workflow

Runner Version and Platform

GH hosted runners

OS of the machine running the runner? OSX/Windows/Linux/...

ubuntu-latest

What's not working?

The job above that calls the reusable workflow fails:

The template is not valid. .github/workflows/image_build.yaml (Line: 56, Col: 14): A mapping was not expected

due to this line: event: ${{ github.event }}

Activity

  1. alwell-kevin commented on Jan 3, 2023

    @alwell-kevin

    @pantelis-karamolegkos, would you mind sharing why you closed this issue for my own edification?

  2. pantelis-karamolegkos commented on Jan 3, 2023

    @pantelis-karamolegkos
    Author

    @alwell-kevin I was using wrong context variable name.

    It should be ${{ github.event_name }} instead of ${{ github.event }}.

  3. alwell-kevin commented on Jan 3, 2023

    @alwell-kevin

    Appreciate the additional context (no pun intended) :D !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions