- 
                Notifications
    
You must be signed in to change notification settings  - Fork 484
 
Refine uv dependency upgrade workflow #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||||||||||||||||||||||||||||
| name: Upgrade uv dependencies | ||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||
| - cron: '0 0 * * MON' | ||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| upgrade: | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Check out repository | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||
| - name: Set up uv | ||||||||||||||||||||||||||||||||
| uses: astral-sh/setup-uv@v2 | ||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||
| - name: Generate timestamp | ||||||||||||||||||||||||||||||||
| id: timestamp | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| echo "date=$(date -u '+%Y-%m-%d')" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||
| echo "slug=$(date -u '+%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||
| - name: Upgrade dependencies | ||||||||||||||||||||||||||||||||
| id: upgrade | ||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -o pipefail | ||||||||||||||||||||||||||||||||
| uv lock --upgrade 2>&1 | tee /tmp/uv-upgrade.log | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| echo "output<<'EOF'" | ||||||||||||||||||||||||||||||||
| cat /tmp/uv-upgrade.log | ||||||||||||||||||||||||||||||||
| echo "EOF" | ||||||||||||||||||||||||||||||||
| } >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||
| - name: Create pull request | ||||||||||||||||||||||||||||||||
| 
         
      Comment on lines
    
      +36
     to 
      +37
    
   
  
    
 | 
||||||||||||||||||||||||||||||||
| - name: Create pull request | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create pull request | |
| if: steps.changes.outputs.has_changes == 'true' | 
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
          
            
              
                
              
            
            Show autofix suggestion
            Hide autofix suggestion
          
      Copilot Autofix
AI 6 days ago
To fix the issue, you should add an explicit permissions block to the workflow to grant only the minimum necessary permissions that the job requires. Since the workflow creates a pull request with changes (commits), the job needs contents: write and pull-requests: write permissions. To minimize risk, add the following block to the job ("upgrade"), immediately after runs-on: ubuntu-latest.
No other changes are required.
File to edit: .github/workflows/uv-upgrade.yml
Change: Add a permissions: block to the upgrade job, specifying only the necessary permissions.
- 
    
    
    
Copy modified lines R11-R13  
| @@ -8,6 +8,9 @@ | ||
| jobs: | ||
| upgrade: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| 
             | 
        ||
| steps: | ||
| - name: Check out repository | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command captures output but doesn't check if
uv lock --upgradeactually made any changes. Consider checking if the lock file was modified before creating a PR to avoid creating empty PRs when no upgrades are available. You could add a git diff check after this step to set a conditional flag.