π μ΄λλ―Ό μ±μ κ΄λ¦¬ νμ΄μ§ νΌκ·Έλ§ λμμΈ λ°μ #39
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: Auto Label PR | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed apps | |
| id: detect | |
| run: | | |
| # Get changed files between base and head | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
| FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA) | |
| echo "Changed files:" | |
| echo "$FILES" | |
| # Check for web changes | |
| if echo "$FILES" | grep -q "^apps/web/"; then | |
| echo "web=true" >> $GITHUB_OUTPUT | |
| echo "β Detected changes in apps/web" | |
| else | |
| echo "web=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Check for admin changes | |
| if echo "$FILES" | grep -q "^apps/admin/"; then | |
| echo "admin=true" >> $GITHUB_OUTPUT | |
| echo "β Detected changes in apps/admin" | |
| else | |
| echo "admin=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Add labels | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const labels = []; | |
| if ('${{ steps.detect.outputs.web }}' === 'true') { | |
| labels.push('web'); | |
| } | |
| if ('${{ steps.detect.outputs.admin }}' === 'true') { | |
| labels.push('admin'); | |
| } | |
| if (labels.length > 0) { | |
| console.log(`Adding labels: ${labels.join(', ')}`); | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: labels | |
| }); | |
| } else { | |
| console.log('No app-specific changes detected'); | |
| } |