Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update PR branches

on:
push:
branches:
- main

jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-22.04
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_FILTER: "all"
PR_READY_STATE: "ready_for_review"
MERGE_MSG: "Auto-updated branch with latest changes from main"
RETRY_COUNT: "2"
RETRY_SLEEP: "60000"
MERGE_CONFLICT_ACTION: "fail"
Comment on lines +10 to +21

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 6 months ago

In general, the fix is to explicitly declare a permissions block so that the GITHUB_TOKEN has only the scopes required for this job. Since this workflow auto-updates PR branches, it needs to read repository contents and update pull requests (and possibly their branches). A common minimal set is contents: write (to push branch updates) and pull-requests: write (to update PR metadata/status if needed). If you know the action only touches branches and not PR metadata, you could restrict to contents: write, but to avoid breaking existing functionality, we’ll allow both.

The best fix without altering existing behavior is to add a permissions block at the job level for autoupdate. This keeps the change local to this workflow and avoids affecting any other workflows that might exist. Concretely, in .github/workflows/autoupdate.yml, under autoupdate: and aligned with runs-on:, insert:

permissions:
  contents: write
  pull-requests: write

No additional methods, imports, or definitions are needed; this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/autoupdate.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml
--- a/.github/workflows/autoupdate.yml
+++ b/.github/workflows/autoupdate.yml
@@ -9,6 +9,9 @@
   autoupdate:
     name: autoupdate
     runs-on: ubuntu-22.04
+    permissions:
+      contents: write
+      pull-requests: write
     steps:
       - uses: docker://chinthakagodawita/autoupdate-action:v1
         env:
EOF
@@ -9,6 +9,9 @@
autoupdate:
name: autoupdate
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
Copilot is powered by AI and may make mistakes. Always verify output.
Loading