-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
workflows/ci: fix template-injection zizmor findings #195318
base: master
Are you sure you want to change the base?
Conversation
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.
Seeing some CI failures with a few of these changes:
Error: The template is not valid. .github/workflows/ci.yml (Line: 193, Col: 30): Error reading JToken from JsonReader. Path '', line 0, position 0.
Error: The template is not valid. .github/workflows/ci.yml (Line: 202, Col: 27): Error reading JToken from JsonReader. Path '', line 0, position 0.
Error: The template is not valid. .github/workflows/ci.yml (Line: 241, Col: 30): Error reading JToken from JsonReader. Path '', line 0, position 0.
.github/workflows/ci.yml
Outdated
run: | | ||
brew ruby -r "$(brew --repository homebrew/cask)/cmd/lib/check.rb" <<'EOF' | ||
require "cask/cask_loader" | ||
require "utils/github/actions" | ||
|
||
before = JSON.parse(<<~'EOS').transform_keys(&:to_sym) | ||
${{ steps.snapshot.outputs.before }} | ||
$SNAPSHOT_BEFORE |
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.
You, probably, need to get this from env, like ENV.fetch("SNAPSHOT_BEFORE")
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.
Ah yeah, I wasn't sure if there was any magic interpolation that would happen but that makes sense.
I've updated this to use JSON.parse(ENV.fetch("SNAPSHOT_BEFORE", "{}")).transform_keys(&:to_sym)
but for some reason before
ends up being nil
even though SNAPSHOT_BEFORE
is clearly set on CI (e.g., https://github.com/Homebrew/homebrew-cask/actions/runs/12365165225/job/34509690180?pr=195318).
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.
Hmm, I don't see anything obvious 🤷
I'd add a couple of debug puts
/env(1)
to see what's missing.
In https://github.com/Homebrew/homebrew-cask/actions/runs/12342912865/job/34443307830?pr=195318 I suspect "Gather cask information" step got skipped, so some variables weren't set, and in the next steps, they're used in |
This updates `workflows/ci.yml` to use an environment variable to address a `template-injection` error from `zizmor`.
ec44051
to
37dc7fd
Compare
This updates `workflows/ci.yml` to use environment variables to address `template-injection` info from `zizmor`.
37dc7fd
to
cdd799b
Compare
Important: Do not tick a checkbox if you haven’t performed its action. Honesty is indispensable for a smooth review process.
In the following questions
<cask>
is the token of the cask you're submitting.After making any changes to a cask, existing or new, verify:
brew audit --cask --online <cask>
is error-free.brew style --fix <cask>
reports no offenses.Additionally, if adding a new cask:
brew audit --cask --new <cask>
worked successfully.HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask <cask>
worked successfully.brew uninstall --cask <cask>
worked successfully.This updates
workflows/ci.yml
to use environment variables toaddress a
template-injection
error and similar info output fromzizmor
.I've added
# shellcheck disable=SC2086
comments in a few places whereshellcheck
wanted quotes but the strings consist of space-separated packages:Adding quotes in those instances would cause
brew
to interpret something like"one two three"
as one package with that name instead of three packages. If there's a better way to handle this, let me know.As with my other recent actions PRs, I'm not very knowledgeable about GitHub Actions, so I've created this as a draft until more knowledgeable maintainers have a chance to review this and catch any mistakes.