Skip to content

Document how to skip a step if a secret isn't present #6861

Description

@jsoref

What article on docs.github.com is affected?

https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif
https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
https://docs.github.com/en/actions/reference/encrypted-secrets

What part(s) of the article would you like to see updated?

  • Something in the if set should mention that secrets. isn't available
  • Something in the context set should mention that secrets. isn't available in if
  • Something in the three should explain how to work around this

Additional information

It is common for projects to include a secret for deploying things and an action that uses that secret.

When one forks that repository, the secret won't be present and the workflow will break.

This experience is incredibly painful.

With just a bit of extra code in a workflow, the ❌ 's go away. But, w/o documentation on how to do it, 99% of workflow authors won't.

Here's an example which fixed one (of a number of failing workflows):
jsoref/argo-cd@ae52e40

 - name: deployif: ${{ github.event_name == 'push' && env.HAVE_PERSONAL_TOKEN == 'true' }}uses: peaceiris/actions-gh-pages@v2.5.0env:
HAVE_PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN != '' }}PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamhelp wantedAnyone is welcome to open a pull request to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions