Created
August 27, 2019 03:50
-
-
Save skwashd/3ffc1ab9230224001455151813b41648 to your computer and use it in GitHub Desktop.
Batch create dependabot config.yml file in github repos
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
#!/usr/bin/env python3 | |
import base64 | |
import os | |
import requests | |
token = os.environ.get("GITHUB_TOKEN") | |
org = os.environ.get("GITHUB_ORG") | |
config_file = os.environ.get("DEPENDABOT_CONFIG_FILE", "dependabot-config.yml") | |
commit_message = "I didn't configure the script properly" | |
name = "Dave's Dependabot Script" | |
email = "[email protected]" | |
repos = [ | |
# Add list of repos here. | |
] | |
with open(config_file, "rb") as f: | |
config = f.read() | |
config_b64 = base64.b64encode(config).decode("utf-8") | |
headers = {"Authorization": f"token {token}"} | |
for repo in repos: | |
url = f"https://api.github.com/repos/{org}/{repo}/contents/.dependabot/config.yml" | |
payload = { | |
"author": {"name": name, "email": email}, | |
"content": config_b64, | |
"message": commit_message, | |
} | |
r = requests.put(url, headers=headers, json=payload) | |
r.raise_for_status() |
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
# Full config file configuration available at https://dependabot.com/docs/config-file/ | |
version: 1 | |
update_configs: | |
- package_manager: "python" | |
directory: "/" | |
update_schedule: "live" | |
automerged_updates: | |
- match: | |
dependency_type: "all" | |
update_type: "semver:minor" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment