Created
February 22, 2024 05:13
-
-
Save ccharlton/3613a2df2864efd266b36f9db10c7e61 to your computer and use it in GitHub Desktop.
Extract variables & secrets from CI/CD workflow folders
This file contains 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/sh | |
# Lists all workflows folder secrets in a simple list | |
echo "" | |
echo "List all secrets/variables in one simple list...\n" | |
grep -oh '\${{ secrets\.[^}]*}}' *.yml | sed 's/\${{ secrets\.\([^}]*\)}}/\1/' | sort | uniq | |
# Extract 'name' from each YML file | |
echo "\n--------------------\n" | |
echo "What does each file do?\n" | |
for file in $(ls *.yml | sort); do | |
name=$(grep -m 1 '^name:' "$file" | sed 's/name: //') | |
echo "$file: $name" | |
done | |
# List each secrets variable per YML file | |
echo "\n--------------------\n" | |
echo "List secrets/variables per YML file...\n" | |
for file in *.yml; do | |
echo "$file" | |
echo "---------------------" | |
grep -oh '\${{ secrets\.[^}]*}}' "$file" | sed 's/\${{ secrets\.\([^}]*\)}}/\1/' | sort | uniq | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment