Skip to content
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

Disable steps that requires secrets in GitHub Action workflows #48

Closed
end2endzone opened this issue Jun 4, 2021 · 2 comments
Closed
Labels

Comments

@end2endzone
Copy link
Owner

end2endzone commented Jun 4, 2021

The 3 GitHub Action workflows for this projects builds and executes tests on multiple platforms. The workflows can be summarized as follows:

  1. At the beginning of the workflow, there is a step that uploads a "test incomplete" badge to one of my gist. This is to override the previous existing badge in case the workflow encounters an error.
  2. Build and run unit tests
  3. At the end of the workflow, a step uploads a green "53 passed" badge such as image to the same gist. This badge overrides the one uploaded at step 1.

Since these 2 steps require the use of secrets environment variable to get write access to the gist.

The problem is they fails when executed as a PR checks because (from the project's Actions secrets page) : "Secrets are not passed to workflows that are triggered by a pull request from a fork. Learn more.".

@end2endzone end2endzone added the bug label Jun 4, 2021
@end2endzone
Copy link
Owner Author

The solution seems to be to disable these steps on pull request. One workaround, would be the following:

  1. Duplicate all existing workflows.
  2. Edit original workflows to only run on "push".
  3. Remove the badge upload steps from the copied workflows and edit them to only run on PR.

@end2endzone
Copy link
Owner Author

The workaround specified above will not be implemented since it would make all workflows hard to maintain and error prone.
The best solution is to add an if statement for each steps that requires a secret. The stack overflow article Only run GitHub Actions step if not a pull request explains how to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant