Skip to content

Commit dd89dc6

Browse files
authored
Merge pull request #6 from yarikoptic/copilot/disable-actions-in-forks
Disable GitHub Actions on forks by default
2 parents d769c53 + d51b37a commit dd89dc6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

common.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ fi
1313
# by grep on github.com/ we would skip ssh ones
1414
if git fetch -v 2>&1 | grep -q github.com/; then
1515
if ! git remote | grep -q "$ghremote" ; then
16-
if ! GH_TOKEN="$GITHUB_TOKEN" gh repo fork --remote --remote-name "$ghremote"; then
16+
if GH_TOKEN="$GITHUB_TOKEN" gh repo fork --remote --remote-name "$ghremote"; then
17+
# disable actions in the fork -- we just want to provide contributions upstream
18+
fork_repo=$(git remote get-url "$ghremote" | sed -e 's|.*github.com[:/]||' -e 's|\.git$||')
19+
GH_TOKEN="$GITHUB_TOKEN" gh api -X PUT "repos/$fork_repo/actions/permissions" -F enabled=false || \
20+
echo "WARNING: Failed to disable actions on fork $fork_repo" >&2
21+
else
1722
echo "errored out, sleeping, trying to fetch"
1823
sleep 2
1924
git fetch "$ghremote"

0 commit comments

Comments
 (0)