-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.sh
More file actions
32 lines (28 loc) · 1.1 KB
/
Copy pathcommon.sh
File metadata and controls
32 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# shellcheck shell=sh
# shellcheck disable=SC2034
branch=$(git rev-parse --abbrev-ref HEAD)
ghuser=$(git config github.user)
ghremote=gh-${ghuser:-mine}
# Just rely on gh being authenticated
#if [ -z "${GITHUB_TOKEN:-}" ]; then
# # if not available -- load from config possibly
# GITHUB_TOKEN=$(git config hub.oauthtoken)
#fi
# by grep on github.com/ we would skip ssh ones
if git fetch -v 2>&1 | grep -q github.com/; then
if ! git remote | grep -q "$ghremote" ; then
if gh repo fork --remote --remote-name "$ghremote"; then
# disable actions in the fork -- we just want to provide contributions upstream
fork_repo=$(git remote get-url "$ghremote" | sed -e 's|.*github.com[:/]||' -e 's|\.git$||')
gh api -X PUT "repos/$fork_repo/actions/permissions" -F enabled=false || \
echo "WARNING: Failed to disable actions on fork $fork_repo" >&2
else
echo "errored out, sleeping, trying to fetch"
sleep 2
git fetch "$ghremote"
fi
fi
mkdir -p .github/workflows
else
echo "Remote does not point to github, fork yourself" >&2
fi