File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env /bin/bash
2
+ set -euo pipefail
3
+
4
+ # ##
5
+ # # GLOBAL VARIABLES
6
+ # ##
7
+ GITHUB_TOKEN=${GITHUB_TOKEN:- ' ' }
8
+ ORG=${ORG:- ' ' }
9
+ API_URL_PREFIX=${API_URL_PREFIX:- ' https://api.github.com' }
10
+ GIT_URL_PREFIX=${GIT_URL_PREFIX:- ' https://github.com' }
11
+ SRC_REPO=$1
12
+ DEST_REPO=$2
13
+ OWNER_USERNAME=${OWNER_USERNAME:- ' ' }
14
+
15
+
16
+ # Create repo
17
+ curl -X POST -H " Authorization: token ${GITHUB_TOKEN} " -H " Accept: application/vnd.github.nebula-preview+json" " ${API_URL_PREFIX} /orgs/${ORG} /repos" -d ' {"name":"' ${DEST_REPO} ' ", "visibility":"internal"}' ;
18
+
19
+ # Grant Admin permissions on new repo
20
+ curl -X PUT -H " Authorization: token ${GITHUB_TOKEN} " -H " Accept: application/vnd.github.v3+json" " ${API_URL_PREFIX} /repos/${ORG} /${DEST_REPO} /collaborators/${OWNER_USERNAME} " -d ' {"permission":"admin"}' ;
21
+
22
+ # Clone old repo locally
23
+ git clone --bare " ${GIT_URL_PREFIX} /${ORG} /${SRC_REPO} .git"
24
+
25
+ # Push to new repo
26
+ cd " ${SRC_REPO} .git"
27
+ git push --mirror " ${GIT_URL_PREFIX} /${ORG} /${DEST_REPO} .git"
28
+
29
+ # Cleanup
30
+ cd ..
31
+ rm -Rf " ${SRC_REPO} .git"
You can’t perform that action at this time.
0 commit comments