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

Detect if the script is running in github action environment #20

Open
oxygen-dioxide opened this issue Mar 13, 2023 · 1 comment
Open
Labels
question Further information is requested

Comments

@oxygen-dioxide
Copy link

oxygen-dioxide commented Mar 13, 2023

If I'm developing a script that runs either locally or in github action, I may want to detect whether it is running in github action environment, because some functions in github-action-utils is unusable locally.
Although I can detect the environment by using try-catch, I still want a more Pythonic solution in the github-action-utils module. For example, a is_github_action() function that returns a bool.

@oxygen-dioxide oxygen-dioxide changed the title Detect if the script in running in github action environment Detect if the script is running in github action environment Mar 13, 2023
@saadmk11 saadmk11 added the question Further information is requested label Mar 20, 2023
@saadmk11
Copy link
Owner

You can use GITHUB_ACTIONS or CI (Always set to true when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions.) environment variables to check if you code is running locally or via GitHub Actions.

ref: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

This is the recommended way provided by GitHub.

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

No branches or pull requests

2 participants