Skip to content

Fix sync-rush-versions workflow permissions for Dependabot PRs - #204

Merged
nev21 merged 2 commits into
mainfrom
copilot/update-sync-rush-workflow
Dec 31, 2025
Merged

nev21 merged 2 commits into
mainfrom
copilot/update-sync-rush-workflow

Conversation

Copilot AI commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor

The sync-rush-versions.yml workflow fails on Dependabot PRs due to read-only GITHUB_TOKEN permissions with the pull_request trigger, preventing it from pushing commits to sync rush.json and regenerate lockfiles.

Changes

  • Trigger: Changed from pull_request to pull_request_target to grant write permissions
  • Checkout references: Updated both jobs to explicitly check out PR head branch:
    - uses: actions/checkout@v6
      with:
        ref: ${{ github.event.pull_request.head.ref }}
        repository: ${{ github.event.pull_request.head.repo.full_name }}

Security

Safe use of pull_request_target as the workflow:

  • Only runs when github.actor == 'dependabot[bot]'
  • Executes no code from the PR, only syncs configuration files
Original prompt

Problem

The sync-rush-versions.yml GitHub Actions workflow is not running on Dependabot pull requests because workflows triggered by Dependabot have read-only GITHUB_TOKEN permissions by default. This prevents the workflow from pushing commits to sync the rush.json file and regenerate lockfiles.

Solution

Update the workflow to use pull_request_target instead of pull_request trigger. This change will:

  • Grant the workflow write permissions needed to push commits
  • Allow the workflow to run properly on Dependabot PRs
  • Maintain security by only running on Dependabot-authored PRs

Required Changes

Update .github/workflows/sync-rush-versions.yml:

  1. Change the trigger from pull_request to pull_request_target
  2. Add explicit checkout references to ensure the PR branch is checked out:
    • Use ref: ${{ github.event.pull_request.head.ref }}
    • Use repository: ${{ github.event.pull_request.head.repo.full_name }}

Security Considerations

Using pull_request_target is safe in this context because:

  • The workflow only runs when github.actor == 'dependabot[bot]'
  • No code from the PR is executed
  • Only configuration files (rush.json, lockfiles) are being synced

References

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…r Dependabot PRs

Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Copilot AI changed the title [WIP] Update sync rush versions workflow for Dependabot PRs Fix sync-rush-versions workflow permissions for Dependabot PRs Dec 31, 2025
Copilot AI requested a review from nev21 December 31, 2025 07:53
@nev21
nev21 marked this pull request as ready for review December 31, 2025 07:54
Copilot AI review requested due to automatic review settings December 31, 2025 07:54
@nev21
nev21 enabled auto-merge (squash) December 31, 2025 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the sync-rush-versions.yml workflow to fix permission issues preventing it from running on Dependabot pull requests. The workflow needs write permissions to push commits that sync rush.json and regenerate lockfiles.

Key Changes:

  • Changed trigger from pull_request to pull_request_target to grant write permissions
  • Updated checkout steps to explicitly reference the PR head branch using github.event.pull_request.head.ref and github.event.pull_request.head.repo.full_name

Comment thread .github/workflows/sync-rush-versions.yml
Comment thread .github/workflows/sync-rush-versions.yml
@nev21
nev21 disabled auto-merge December 31, 2025 08:07
@nev21
nev21 merged commit 6d59768 into main Dec 31, 2025
13 checks passed
@nev21
nev21 deleted the copilot/update-sync-rush-workflow branch December 31, 2025 08:07
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.

3 participants