Skip to content

Conversation

@Ronitsabhaya75
Copy link
Contributor

@Ronitsabhaya75 Ronitsabhaya75 commented Oct 19, 2025

Type of Change

  • Added the split approach @katiewasnothere suggested using openssf
  • Added adtiional feature for colors

Motivation and Context

This can basically Help teams know what changes are made in pr

Testing

  • Tested locally
Currently this is for CLI only later we can add multiple

Structure how workflow runs

 Pull Request Opened (untrusted code) 
             ↓

**pr-label-analysis.yml (Read-only)**
- Analyzes files using native git commands
- No secrets, no write permissions
- No third-party actions
- Saves to artifact
             ↓

- Artifact Storage
- PR number + labels
             ↓

**pr-label-apply.yml (Write access)**
- Never touches PR code
- Only reads artifact data
- Uses GitHub official actions only
- Applies labels via github-script

             ↓

🏷️ Labels Applied!

github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = [
{ name: 'cli', color: '0E8A16', description: 'Changes to CLI components' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of trying to encode the different label categories into the workflow job itself, maybe instead we could use the PR number parameter to actions/labeler in the label-apply workflow like this:

    - uses: actions/labeler@v6
      with:        
        pr-number: |
          1
          <PR number we got from the artifact download>

We should double check that the labeler doesn't try to read the untrusted code. But my understanding is that the action does not checkout the PR code, just analyzes based on the files that have been changed.

Note: I think it would be unsafe to read the labeler's configuration file from the PR, we might have to settle for using the configuration in main. But we should look into that as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, Katie! I've updated the workflows to use actions/labeler@v5 with the PR number from the artifact as you recommended.

Comment on lines 11 to 12
permissions:
issues: write
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #781, the top level permissions should always be the least permissive possible and any additional permissions should be set at the job level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the permissiion to read only

@Ronitsabhaya75
Copy link
Contributor Author

@katiewasnothere can you look at the changes I made please let me know if they are good

@@ -0,0 +1,65 @@
name: Color Labels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this. We can make them by hand for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i remvoe the colors file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

with:
pr-number: ${{ steps.pr-number.outputs.number }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have checked out the repo to access this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to checkout the repository to access the .github/labeler.yml configuration file. Without checkout, the workflow runner won't have access to any files from the repo, including the labeler configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the repo being checked out in this workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I accidentally removed it let me add it again. Thank you Katie for pointing that out.

@jglogan jglogan self-requested a review October 25, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants