aboutsummaryrefslogtreecommitdiffstats
path: root/gh-clone.sh
diff options
context:
space:
mode:
Diffstat (limited to 'gh-clone.sh')
-rwxr-xr-xgh-clone.sh25
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 \