-
Notifications
You must be signed in to change notification settings - Fork 60.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to use secrets with if:
conditionals in GitHub Actions workflows
#12722
Conversation
Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines. |
Automatically generated comment ℹ️This comment is automatically generated and will be overwritten every time changes are committed to this branch. The table contains an overview of files in the Content directory changesYou may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.
|
@br3ndonland |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@br3ndonland Thank you for this addition! I think this info will be super helpful to users. I don't have permissions to edit your PR to resolve the merge conflict. The file has been renamed to |
content/actions/using-workflows/workflow-syntax-for-github-actions.md
Outdated
Show resolved
Hide resolved
#6861 #12722 (comment) Rather than referencing two secrets: 1. `${{ secrets.SECRET_IS_SET }}` 2. `${{ secrets.SECRET_IS_NOT_SET }}`) This commit will update the related section of the docs to reference a single secret (`${{ secrets.SECRET_IS_SET }}`), and will update the `if:` conditionals to compare with empty strings as suggested.
#6861 #12722 (comment) This PR adds an example of how to use secrets with `if:` conditionals. The reviewer suggested comparing variable values with empty strings to make the `if:` conditionals clearer. Commit cecdf00 updated the secret names accordingly, but the names of the secret and environment variable may still have been confusing. This commit will update the secret and environment variable names to match the cross-referenced example on the "Encrypted secrets" page.
content/actions/using-workflows/workflow-syntax-for-github-actions.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@br3ndonland - This looks great. Thanks for making this change.
The example is really good. I'm sure this will help a lot of people. 👍
I'll get this merged/published.
Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues ⚡ |
I think this would deserve a hint on the implication that the secret is leaked to every step within the job, regardless if it's required for a certain step or not (hence violating the principle of least privilege). |
Hey @m-kuhn 👋 - Since this PR has already been merged and issue closed, could you create a new issue with your suggestions? Then we can triage it for team review. ⚡ Thanks for your interest in improving our docs! 💖 |
Why:
Closes #6861
Users have requested documentation on how to use secrets with
if:
conditionals, especially how to skip a GitHub Actions workflow step if a secret isn't present.This PR is based on the helpful guidance provided in #6861 (comment).
Related to this, as far as I know, the docs don't mention the default return value for an expression referencing an unset secret. Based on trial and error, the return value of
${{ secrets.SECRET_IS_NOT_SET }}
appears to be an empty string. I've been digging around actions/runner to try to find where this default value is set, but I'm not sure. Maybe inSecretUtility.cs
?What's being changed:
jobs.<job_id>.steps[*].if
, demonstrating how to skip a step if a secret is not presentCheck off the following:
Writer impact (This section is for GitHub staff members only):