shayanorellana:

ex: MongoClient(username: mongodb_pass) instead of having the password in plain sight in the script.

Not having the credentials directly in the script is good practice, yes. That has nothing to do with masking, though.

You can use environment variable just like in the Actions workflow, you’ll just have to set them when you run the script. Just be aware of what else you run in the same environment and of shell history (if you use Bash, HISTCONTROL is your friend).

An alternative is to use a config file, just read the values from another file instead of coding them into the script. Python has built-in parsers for JSON and INI-style files. I like YAML, but that requires installing PyYAML. Obviously don’t commit that file, I recommend adding it to .gitignore.

You can even support both in your script: Read environment variables or config file depending on command line options or simply what’s available.

🌐
Netlify
canovasjm.netlify.app › 2021 › 01 › 12 › github-secrets-from-python-and-r
GitHub Secrets from Python and R - JM - Netlify
The syntax to call a secret is the following: ${{ secrets.SECRET_NAME }} ... - name: execute py script # email-from-python.py env: EMAIL_SENDER: ${{ secrets.EMAIL_SENDER }} EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} EMAIL_RECIPIENT: ${{ secrets.EMAIL_RECIPIENT }} run: python email-from-python.py
Discussions

How to pass secrets from GitHub Actions to python environ variables? - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... To run pytest within GitHub Actions, I have to pass some secrets for Python ... More on stackoverflow.com
🌐 stackoverflow.com
python - Using github with secret keys - Stack Overflow
I have a Python script with secret keys for the Tweeter API. I would like to version control my script using Github. How do I keep my keys secret while still uploading to Github? That is, the value... More on stackoverflow.com
🌐 stackoverflow.com
March 15, 2015
Manage your GitHub Actions secrets, with a simple Python script
🌐 r/github
2
7
April 15, 2020
Using secrets for code and database credentials
Hi there I am currently working with colleagues on a small webapp that is based on PHP and a database. We have set up a workflow where every push to the master branch copies the repository to our t... More on github.com
🌐 github.com
20
10
🌐
PyPI
pypi.org › project › githubsecrets
githubsecrets · PyPI
Create a GitHub secret, use the -r flag and supply the repository's name. You can apply the same secret to multiple repositories at once, for example: -r "githubsecrets, aws-build-badges" ... steps: - uses: actions/checkout@v2 - name: Set up ...
      » pip install githubsecrets
    
Published   Nov 05, 2020
Version   1.0.8
🌐
GitHub
github.com › mbacchi › python-git-secrets
GitHub - mbacchi/python-git-secrets: A pure Python library providing git-secrets functionality.
(venv) [mbacchi@hostname python-git-secrets]$ python test_driver.py .... ---------------------------------------------------------------------- Ran 4 tests in 0.005s OK ... Distributed under the BSD (Simplified) license.
Starred by 4 users
Forked by 5 users
Languages   Python 96.7% | Makefile 3.3% | Python 96.7% | Makefile 3.3%
Find elsewhere
🌐
Reddit
reddit.com › r/github › manage your github actions secrets, with a simple python script
r/github on Reddit: Manage your GitHub Actions secrets, with a simple Python script
April 15, 2020 -

Hi all,

I found myself struggling with managing the GitHub Actions secrets from UI, so I wrote a very simple Python script which acts as a CLI - https://github.com/unfor19/githubsecrets

Enjoy!

🌐
YouTube
youtube.com › watch
How To Use GitHub Action Secrets In Your Python Script In 3 Steps - YouTube
Step-by-step guide on how to use GitHub Action Secrets in a Python script that can be used for any Python script.
Published   January 10, 2023
🌐
GitHub
github.com › davedittrich › python_secrets
GitHub - davedittrich/python_secrets: Python CLI for managing secrets and eliminating default passwords in FOSS · GitHub
The name of the environment can be provided explicitly, or it can be inferred from the base name of the current working directory: $ pwd /Users/dittrich/git/python_secrets $ psec environments create environment directory /Users/dittrich/.secrets/python_secrets created $ tree ~/.secrets /Users/dittrich/.secrets └── python_secrets └── secrets.d 2 directories, 0 files
Starred by 16 users
Forked by 6 users
Languages   Python 90.1% | Shell 8.0% | Makefile 1.9%
🌐
Medium
medium.datadriveninvestor.com › accessing-github-secrets-in-python-d3e758d8089b
Accessing GitHub secrets in Python | by Dipam Vasani | DataDrivenInvestor
April 21, 2021 - You can use it to store tokens, account details, passwords, anything you would want to encrypt. Join Medium for free to get updates from this writer. ... To add a new secret, go to your GitHub repository > Settings > Secrets > New Repository Secret.
🌐
PyPI
pypi.org › project › python-git-secrets
python-git-secrets · PyPI
(venv) [mbacchi@hostname python-git-secrets]$ python samples/python-git-secrets.py --scan flask-quotes --repository https://github.com/mbacchi/flask-quotes --use_local_repo -r Scanning flask-quotes recursively flask-quotes SCANNING: flask-quotes/app.py Found verboten string in path flask-quotes
      » pip install python-git-secrets
    
Published   Feb 17, 2020
Version   0.1.3
🌐
Medium
saurabh-sawhney.medium.com › o-github-tell-me-your-secrets-c06130bd4c2e
O GitHub, tell me your secrets - Saurabh - Medium
November 30, 2023 - The quest undertaken by this workflow is to access THE_SECRET from within the bowels of GitHub and nurture it in the compute environment while the python script runs. Here’s the yaml file for the GitHub action. name: King Arthur on: workflow_dispatch: jobs: sword-pulling: runs-on: ubuntu-latest steps: - name: Checkout repos code uses: actions/checkout@v3 - name: the excalibur env: THE_SECRET: ${{ secrets.THE_SECRET_YOU_WISH_TO_UNCOVER }} run: python scripts/the-secret.py
🌐
GitHub
gist.github.com › 9a53bb00767a16d6646464c4b8249094
Create Github Secrets when you are not the owner and dont have access from the UI · GitHub
Save comdotlinux/9a53bb00767a16d6646464c4b8249094 to your computer and use it in GitHub Desktop. ... Create the two files, requirements.txt and github_create_secret.py in this directory (being in this directory is not necessary but eases documentation)
🌐
GitHub
github.com › clarkritchie › 1pw-github-secrets › blob › main › README.md
1pw-github-secrets/README.md at main · clarkritchie/1pw-github-secrets
This project is a small Python script that reads secrets from 1Password, and pushes them into GitHub as either a) environment secrets within a project, b) repoistory secrets, or c) organization secrets. It was originally forked from an article I found on Medium, but was later customized for my needs. There are 2 ways to use this project, either as a GitHub Action or as a command line tool.
Author   clarkritchie
🌐
GitHub
github.com › orgs › community › discussions › 53300
How do you get a secret? · community · Discussion #53300
... Using os.getenv() (or maybe nicer, os.environ) goes into the right direction. The trick is that you'll need to put the secret into an environment variable for the step in which your code runs, e.g.:
🌐
GitHub
github.com › topics › secrets
secrets · GitHub Topics · GitHub
Porch Pirate can be used as a client or be incorporated into your own applications. security osint secrets postman recon scanning devsecops ... 🕵️ Python project to crawl for JavaScript files and search for secrets like API keys, authorization tokens, hardcoded password or related.
🌐
GitHub
github.com › python › cpython › blob › main › Lib › secrets.py
cpython/Lib/secrets.py at main · python/cpython
managing secrets such as account authentication, tokens, and similar. ... See PEP 506 for more information.
Author   python