diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2023-02-15 00:19:09 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-10-14 13:45:10 +0200 |
commit | b96c497b2f37985e1f404082d0c32668f9f18313 (patch) | |
tree | d0e4c54d14bf87d46d832ecfcc6c45ed05e3e090 /gh-clone.sh | |
parent | a5463e863c2ffa9e0e52166b9e8abb337a15dab8 (diff) | |
download | hlupak-b96c497b2f37985e1f404082d0c32668f9f18313.tar.gz |
Set some attributes of new repository
Also, don't use user specific credential helpers, but git-credentials(1)
Diffstat (limited to 'gh-clone.sh')
-rwxr-xr-x | gh-clone.sh | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gh-clone.sh b/gh-clone.sh index 1cefa32..76e7787 100755 --- a/gh-clone.sh +++ b/gh-clone.sh @@ -1,8 +1,6 @@ #!/bin/bash set -eux -USERNAME=$(git config github.user) -PASSWORD=$(pass show dev/github.com|awk '/^token:/ {print $2}') ORGANIZATION="openSUSE-Python" cd /home/pymirrors/repos/ @@ -27,10 +25,31 @@ git clone "https://github.com/${ORIG_REPO}.git" cd "${DIRNAME}" -curl -s -u "${USERNAME}:${PASSWORD}" \ +# Get credentials +CREDS=$(echo 'url=https://github.com/${ORIG_REPO}.git'|git credential fill) +PASSWORD=$(awk -F= '/password/ { print $2 ; exit }') + +# Fork repository +curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${PASSWORD}" \ --json "{ \"organization\": \"${ORGANIZATION}\" , \ \"default_branch_only\": \"true\" }" \ "https://api.github.com/repos/${ORIG_REPO}/forks" >"${GH_TMP_DATA}" + +# Set defaults of the repository (we have to first switch alerts on, to switch off fixes) +curl -s -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${PASSWORD}" \ + "https://api.github.com/repos/${NEW_REPO}/vulnerability-alerts" +curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${PASSWORD}" \ + "https://api.github.com/repos/${NEW_REPO}/automated-security-fixes" +curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${PASSWORD}" \ + "https://api.github.com/repos/${NEW_REPO}/vulnerability-alerts" + +# Set the main branch protected +# DEF_BRANCH=$(awk -F '"' '/default_branch/ {print $4; exit}' "${GH_TMP_DATA}") +# Somehow doesn't work FIXME +# curl -s -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${PASSWORD}" \ +# "https://api.github.com/repos/${NEW_REPO}/branches/${DEF_BRANCH}/protection/enforce_admins" + +# Set remotes correctly git remote add github \ "$(awk -F '"' '/clone_url/ {print $4 ; exit}' "${GH_TMP_DATA}")" git remote set-url --push github \ |