Created
January 13, 2025 08:20
-
-
Save celeroncoder/9f890b10dd2899abff9cc323cce01b7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if .env file exists | |
if [ ! -f .env ]; then | |
echo ".env file not found!" | |
exit 1 | |
fi | |
# Read the repository name and owner | |
REPO="your-username/your-repo" # Change this to your GitHub repo | |
# Alternatively, you can use the current repo | |
# REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner) | |
# Read the .env file and set GitHub secrets | |
while IFS='=' read -r key value; do | |
# Skip empty lines and comments | |
if [[ -z "$key" || "$key" == \#* ]]; then | |
continue | |
fi | |
# Trim whitespace | |
key=$(echo "$key" | xargs) | |
value=$(echo "$value" | xargs) | |
# Add secret to GitHub | |
echo "Adding secret: $key" | |
gh secret set "$key" --body "$value" --repo "$REPO" | |
done < .env | |
echo "All secrets added successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment