Skip to content

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

Closed

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: deploy
        if: ${{ github.event_name == 'push' && env.HAVE_PERSONAL_TOKEN == 'true' }}
        uses: peaceiris/actions-gh-pages@v2.5.0
        env:
          HAVE_PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN != '' }}
          PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

Activity

  1. added
    contentThis issue or pull request belongs to the Docs Content team
    on May 28, 2021
  2. added
    triageDo not begin working on this issue until triaged by the team
    on May 28, 2021
  3. janiceilene commented on May 28, 2021

    @janiceilene
    Contributor

    Thanks for opening an issue @jsoref! I'll triage this for the team to take a look 👀

  4. added
    actionsThis issue or pull request should be reviewed by the docs actions team
    and removed
    triageDo not begin working on this issue until triaged by the team
    on May 28, 2021
  5. skedwards88 commented on Jun 29, 2021

    @skedwards88
    Contributor

    Thank you for opening this issue! I have modified your suggestion for how to change the docs:

    1. We document that the secrets context is not available in if statements in the "Context availability" section of "Context and expression syntax for GitHub Actions", so I recommend leaving this article as is.

    2. I think you are right that we could additionally call this out in the "if" sections in Workflow syntax for GitHub Actions. For example, adding a sentence like

      Not all contexts are available to if statements.

      before

      For more information, see "Context and expression syntax for GitHub Actions."

    3. Additionally, I think you are right that users would find a workaround helpful given how many issues and discussions have been opened with this request. An example could be added to the end of the "Using encrypted secrets in a workflow" section in "Encrypted secrets", prefaced with a sentence describing the use case. Here is a simplified example:

    on: push
    jobs:
      my-jobname:
        runs-on: ubuntu-latest
        env:
           MY_SECRET: ${{ secrets.MY_SECRET }}
        steps:
          - if: ${{ env.MY_SECRET }}
            run: echo "I have the secret!"
    

    You or anyone else is welcome to open a PR to make these changes.

  6. added
    help wantedAnyone is welcome to open a pull request to fix this issue
    on Jun 29, 2021
  7. KingofAngma commented on Jul 14, 2021

    @KingofAngma
  8. added
    staleThere is no recent activity on this issue or pull request
    on Oct 8, 2021
  9. jsoref commented on Oct 17, 2021

    @jsoref
    ContributorAuthor

    I might do it at some point, but I'm hoping someone will pick it up first...

  10. added
    triageDo not begin working on this issue until triaged by the team
    on Oct 17, 2021
  11. removed
    triageDo not begin working on this issue until triaged by the team
    staleThere is no recent activity on this issue or pull request
    on Oct 18, 2021
  12. added
    triageDo not begin working on this issue until triaged by the team
    on Oct 18, 2021
  13. removed
    triageDo not begin working on this issue until triaged by the team
    on Oct 18, 2021
  14. added a commit that references this issue on Aug 8, 2024
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

    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