Skip to content

Pass the current workflow to the actions #825

Description

@simon-engledew

Describe the enhancement

In order to get the currently executing workflow file you can make two requests to GitHub APIs:

GET /repos/:owner/:repo/actions/runs/:run_id

and

GET /repos/:owner/:repo/actions/runs/:run_id

It would be cool if:

  • The relative path of the workflow was exposed in an environment variable, e.g: GITHUB_WORKFLOW_PATH

and / or

  • The current workflow was written to a temporary file in a similar way to GITHUB_EVENT_PATH.

This would allow actions to introspect their own workflow.

In our case, the driver for this is linting common workflow mistakes and suggesting ways to fix them.

The benefits of writing the workflow to a temporary file are:

  • You can introspect the workflow even if checkout hasn't been run yet.
  • If there are ever any workflow templating features added in future you will get the workflow AFTER the template has been applied.

Code Snippet

- run: echo "the currently running workflow is at: ${{GITHUB_WORKFLOW_PATH}}"

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions