Skip to content

Update setup-repo.yml #2

Update setup-repo.yml

Update setup-repo.yml #2

Workflow file for this run

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\"]}"