Skip to content

Commit 73a1b40

Browse files
authored
Update setup-new-repo.yml
1 parent 451564e commit 73a1b40

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

.github/workflows/setup-new-repo.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,25 @@ jobs:
157157
- name: Set team permissions
158158
run: |
159159
if gh api orgs/$OWNER/teams > /dev/null 2>&1; then
160-
gh api orgs/$OWNER/teams/$MAINTAINERS_TEAM/repos/$OWNER/$REPO_NAME -X PUT -f permission=triage
161-
gh api orgs/$OWNER/teams/$CODEOWNERS_TEAM/repos/$OWNER/$REPO_NAME -X PUT -f permission=write
162-
gh api orgs/$OWNER/teams/admins/repos/$OWNER/$REPO_NAME -X PUT -f permission=maintain
160+
if gh api orgs/$OWNER/teams/$MAINTAINERS_TEAM > /dev/null 2>&1; then
161+
gh api orgs/$OWNER/teams/$MAINTAINERS_TEAM/repos/$OWNER/$REPO_NAME \
162+
-X PUT -H "Accept: application/vnd.github+json" -f permission=triage || \
163+
echo "::error::Failed to set permissions for $MAINTAINERS_TEAM. Please check team and repository availability."
164+
else
165+
echo "::error::Team $MAINTAINERS_TEAM does not exist. Cannot assign permissions."
166+
exit 1
167+
fi
168+
if gh api orgs/$OWNER/teams/$CODEOWNERS_TEAM > /dev/null 2>&1; then
169+
gh api orgs/$OWNER/teams/$CODEOWNERS_TEAM/repos/$OWNER/$REPO_NAME \
170+
-X PUT -H "Accept: application/vnd.github+json" -f permission=write || \
171+
echo "::error::Failed to set permissions for $CODEOWNERS_TEAM. Please check team and repository availability."
172+
else
173+
echo "::error::Team $CODEOWNERS_TEAM does not exist. Cannot assign permissions."
174+
exit 1
175+
fi
176+
gh api orgs/$OWNER/teams/admins/repos/$OWNER/$REPO_NAME \
177+
-X PUT -H "Accept: application/vnd.github+json" -f permission=maintain || \
178+
echo "::error::Failed to set permissions for admin team. Please check team and repository availability."
163179
else
164180
echo "Skipping team permission assignment — not running in an organization."
165181
fi

0 commit comments

Comments
 (0)