Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Create PR to merge main into release branch
# In the first period after branching the release branch, we typically want to include many changes from `main` in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
permissions:
contents: read
Copy link
Collaborator

@jakepetroules jakepetroules Oct 10, 2025

Choose a reason for hiding this comment

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

I think this may be incorrect. This workflow needs to write to the repository by creating a branch and opening a pull request.

Copy link
Author

Choose a reason for hiding this comment

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

As per security best practices, adopt the principle of least privilege, which often involves multiple “permissions” statements, including top-level and job-level permissions.

The original

permissions:
      contents: write
      pull-requests: write

at the create_merge_pr job level is still there.


Compare to the LLVM project:

Top-level: contents read, e.g. https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L3-L4 -> this makes it future-proof

Job-level: Allow write permissions as needed, e.g. https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L53-L58

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you are saying the default configuration sets the pull-requests and contents permissions to write, and you are trying to set the contents permission back to read here, while continuing to inherit write for pull-requests?

on:
schedule:
- cron: '0 9 * * MON'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Pull request

permissions:
contents: read

on:
pull_request:
types: [opened, reopened, synchronize]
Expand Down
Loading