diff --git a/scripts/dependabot_pr.sh b/scripts/dependabot_pr.sh new file mode 100644 index 0000000..e1b95b6 --- /dev/null +++ b/scripts/dependabot_pr.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Ensure the first command-line argument is provided +if [ -z "$1" ]; then + echo "Error: No GitHub repository URL provided." + echo "Usage: $0 " + exit 1 +fi + +# Set REPO_URL to the first command-line parameter +REPO_URL=$1 + +# Set other variables +REPO_NAME=$(basename -s .git ${REPO_URL}) # Extract the repo name +BRANCH_NAME="dependabot" +PR_TITLE="Keep GitHub Actions up to date with GitHub's Dependabot" +PR_BODY=$(cat < .github/dependabot.yml +${DEPENDABOT_YML} +EOF + +# Stage, commit the changes +git add .github/dependabot.yml +git commit -m"${PR_TITLE}" + +# Push the new branch to origin +git push origin ${BRANCH_NAME} + +# Create a pull request, using the dynamically determined default branch +gh pr create --title "${PR_TITLE}" --body "${PR_BODY}" --base ${DEFAULT_BRANCH} --head ${BRANCH_NAME}