-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Do not attempt to send screenshots to Pixel Eagle without a token #16655
Do not attempt to send screenshots to Pixel Eagle without a token #16655
Conversation
…N - let's use that to our advantage!
jobs: | ||
send-to-pixel-eagle: | ||
name: Send screenshots to Pixel Eagle | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Notify user on non-existent token | ||
if: ${{ ! fromJSON(env.PIXELEAGLE_TOKEN_EXISTS) }} |
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.
In case you're curious:
- Environment variables are stored as strings. However, the strings
'true'
and'false'
are valid JSON, and return booleans when converted to JSON. - This
if:
has to be on the steps - anif:
conditional on the job itself cannot access to environment variables for some reason.
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.
Your current approach works, which is why I'm approving it, but we can improve it by checking what repository this is being run from.
By adding if: ${{ github.repository == "bevyengine/bevy" }}
, we can skip saving the secret to an environmental variable and the various other checks.
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.
Could you please remove the old logic, since it no longer has any effect? (Also I'd rather avoid putting secrets in environmental variables if possible.)
It does have an effect, though. In the old version, if With the logic I added, it sets an environment variable
I agree - and this is why the environment variable isn't the secret itself, but rather a boolean, the result of checking if |
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.
Oh, you're right! I misread:
PIXELEAGLE_TOKEN_EXISTS: ${{ secrets.PIXELEAGLE_TOKEN != '' }}
as
PIXELEAGLE_TOKEN_EXISTS: ${{ secrets.PIXELEAGLE_TOKEN }}
so I thought the environmental variable stored the secret directly. Sorry for confusion, approved!
Objective
Running Github Actions on forks helps users to reduce the amount of CI errors they get before submitting a PR. However, due to how workflows are set up on the Bevy repository, this can result in errors occurring for jobs that may not be related to their PR - in this case, uploading screenshots to Pixel Eagle.
Solution
The Pixel Eagle workflow is skipped if we aren't running on the Bevy repository.
If we are on the Bevy repository, or the user has set it to run elsewhere, we check if the
PIXELEAGLE_TOKEN
secret is set. If it isn't, we skip uploading screenshots to Pixel Eagle.PIXELEAGLE_TOKEN
secret isn't set, we generate a step summary that notifies the user of why it was skipped. https://github.com/LikeLakers2/bevy/actions/runs/12173329006/attempts/1#summary-33953502068 for an example.Testing
Lots. And lots. Of trying to get Github Actions to work with me.