Created
June 6, 2025 01:24
-
-
Save b-/0a4c535b90115eb89344de4343fa50ff to your computer and use it in GitHub Desktop.
generate-docker-compose-dependabot.sh
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 | |
# https://medium.com/@svenvanginkel/automating-dependabot-for-docker-compose-13acdff61133 | |
set -euo pipefail | |
mkdir -p .github | |
tmpfile=$(mktemp) | |
trap 'rm -f "$tmpfile"' EXIT | |
# Header | |
cat > "$tmpfile" <<'YAML' | |
version: 2 | |
updates: | |
- package-ecosystem: "docker-compose" | |
directories: | |
YAML | |
# Find and sort all docker-compose.yml directories | |
find . -regex '.*/\(docker-\)?compose\(-[\w]+\)?\(?>\.[\w-]+\)?\.ya?ml' -print0 \ | |
| xargs -0 -n1 dirname \ | |
| sed 's|^\./||' \ | |
| sort \ | |
| while read -r dir; do | |
echo " - \"/$dir\"" >> "$tmpfile" | |
done | |
# Append the schedule block | |
cat >> "$tmpfile" <<'YAML' | |
schedule: | |
interval: "monthly" | |
YAML | |
# Install if changed | |
if ! [ -f .github/dependabot.yml ] || ! cmp -s "$tmpfile" .github/dependabot.yml; then | |
mv "$tmpfile" .github/dependabot.yml | |
echo "✅ Updated .github/dependabot.yml!" | |
else | |
echo "ℹ️ No changes to .github/dependabot.yml." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment