Skip to content

Commit 24211c0

Browse files
Update setup-repo.yml
1 parent 20847c5 commit 24211c0

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

.github/workflows/setup-repo.yml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Initial Repository Setup
1+
name: Auto-tag Repo After Template Use
22

33
on:
44
push:
@@ -7,42 +7,30 @@ on:
77

88
permissions:
99
contents: write
10-
issues: write
11-
pull-requests: write
1210

1311
jobs:
14-
setup:
15-
name: Setup Repo After First Commit
12+
tag-repo:
1613
runs-on: ubuntu-latest
1714

1815
steps:
19-
- name: Checkout code
20-
uses: actions/checkout@v4
21-
22-
- name: Add collaborators (example)
23-
uses: peter-evans/create-or-update-comment@v3
24-
with:
25-
token: ${{ secrets.GITHUB_TOKEN }}
26-
issue-number: 1
27-
body: |
28-
✅ Automated Setup Triggered!
29-
Please wait while project-level configurations are applied.
16+
- name: Extract repo name
17+
id: extract
18+
run: |
19+
REPO_NAME="${{ github.repository }}"
20+
REPO_ONLY="${REPO_NAME#*/}"
21+
echo "repo_only=$REPO_ONLY" >> $GITHUB_OUTPUT
3022
31-
- name: Configure Collaborators via API
23+
- name: Parse and set topics
3224
env:
33-
GH_TOKEN: ${{ secrets.REPO_SETUP_TOKEN }} # Use a fine-grained PAT stored in org secrets
34-
REPO_NAME: ${{ github.repository }}
25+
GH_TOKEN: ${{ secrets.REPO_SETUP_TOKEN }}
26+
REPO: ${{ github.repository }}
27+
REPO_NAME: ${{ steps.extract.outputs.repo_only }}
3528
run: |
36-
# Example collaborators to add (edit as needed)
37-
curl -X PUT -H "Authorization: token $GH_TOKEN" \
38-
-H "Accept: application/vnd.github+json" \
39-
https://api.github.com/repos/$REPO_NAME/collaborators/username1 \
40-
-d '{"permission":"push"}'
29+
IFS='_' read -r _ DEPT SUBJECT TITLE SECTION ID <<< "$REPO_NAME"
4130
42-
curl -X PUT -H "Authorization: token $GH_TOKEN" \
43-
-H "Accept: application/vnd.github+json" \
44-
https://api.github.com/repos/$REPO_NAME/collaborators/username2 \
45-
-d '{"permission":"push"}'
31+
echo "Applying topics: $DEPT $SUBJECT $SECTION"
4632
47-
- name: Success message
48-
run: echo "✅ Repo initialized and collaborators added!"
33+
curl -X PATCH -H "Authorization: token $GH_TOKEN" \
34+
-H "Accept: application/vnd.github+json" \
35+
https://api.github.com/repos/$REPO \
36+
-d "{\"topics\": [\"$DEPT\", \"$SUBJECT\", \"$SECTION\"]}"

0 commit comments

Comments
 (0)