Skip to content

Instantly share code, notes, and snippets.

@ccharlton
Created February 22, 2024 05:13
Show Gist options
  • Save ccharlton/3613a2df2864efd266b36f9db10c7e61 to your computer and use it in GitHub Desktop.
Save ccharlton/3613a2df2864efd266b36f9db10c7e61 to your computer and use it in GitHub Desktop.
Extract variables & secrets from CI/CD workflow folders
#!/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