-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (29 loc) · 966 Bytes
/
setup-repo.yml
File metadata and controls
36 lines (29 loc) · 966 Bytes
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
33
34
35
36
name: Auto-tag Repo After Template Use
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag-repo:
runs-on: ubuntu-latest
steps:
- name: Extract repo name
id: extract
run: |
REPO_NAME="${{ github.repository }}"
REPO_ONLY="${REPO_NAME#*/}"
echo "repo_only=$REPO_ONLY" >> $GITHUB_OUTPUT
- name: Parse and set topics
env:
GH_TOKEN: ${{ secrets.REPO_SETUP_TOKEN }}
REPO: ${{ github.repository }}
REPO_NAME: ${{ steps.extract.outputs.repo_only }}
run: |
IFS='_' read -r _ DEPT SUBJECT TITLE SECTION ID <<< "$REPO_NAME"
echo "Applying topics: $DEPT $SUBJECT $SECTION"
curl -X PATCH -H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/$REPO \
-d "{\"topics\": [\"$DEPT\", \"$SUBJECT\", \"$SECTION\"]}"