Update setup-repo.yml #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Assign Topics Automatically | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| # This ensures it runs only once after repo is created with initial push | ||
| jobs: | ||
| assign-topics: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| repository-projects: write | ||
| metadata: write | ||
| steps: | ||
| - name: Extract Repo Info | ||
| id: extract | ||
| run: | | ||
| REPO="${GITHUB_REPOSITORY##*/}" | ||
| echo "Full Repo Name: $REPO" | ||
| IFS='_' read -r INSTITUTE DEPT COURSE PROJECT SECTION TEAM <<< "$REPO" | ||
| echo "institute=$INSTITUTE" >> $GITHUB_OUTPUT | ||
| echo "department=$DEPT" >> $GITHUB_OUTPUT | ||
| echo "course=$COURSE" >> $GITHUB_OUTPUT | ||
| echo "project=$PROJECT" >> $GITHUB_OUTPUT | ||
| echo "section=$SECTION" >> $GITHUB_OUTPUT | ||
| echo "team_id=$TEAM" >> $GITHUB_OUTPUT | ||
| - name: Set Topics via GitHub API | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh api repos/${{ github.repository }} \ | ||
| --method PUT \ | ||
| -H "Accept: application/vnd.github.mercy-preview+json" \ | ||
| -f name='${{ github.event.repository.name }}' \ | ||
| -f description='Auto-tagged repository for ${{ steps.extract.outputs.project }} project' \ | ||
| -F topics='${{ steps.extract.outputs.institute }},${{ steps.extract.outputs.department }},${{ steps.extract.outputs.course }},${{ steps.extract.outputs.project }},${{ steps.extract.outputs.section }},${{ steps.extract.outputs.team_id }}' | ||