[llvm] ci: Fix `pr-code-format` permissions for private forks (PR #120838)

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 21 06:30:57 PST 2024


https://github.com/whisperity created https://github.com/llvm/llvm-project/pull/120838

The action requires the ability to change the contents of a pull request (by adding the formatting-related comment) which is only possible through the `write` permission, but if this permission is missing, potential private forks with Actions enabled will break, and because the action triggers on `pull_request_target` even a PR initially fixing this issue downstream will not exhibit the fix until merged.

>From c72373b8be62c4d14f9fa573ba49ca48b61a7c4d Mon Sep 17 00:00:00 2001
From: Whisperity <whisperity at gmail.com>
Date: Sat, 21 Dec 2024 15:07:27 +0100
Subject: [PATCH] ci: Fix `pr-code-format` permissions for private forks

The action requires the ability to change the contents of a pull request (by
adding the formatting-related comment) which is only possible through
the `write` permission, but if this permission is missing, potential
private forks with Actions enabled will break, and because the action
triggers on `pull_request_target` even a PR initially fixing this issue
downstream will not exhibit the fix until merged.
---
 .github/workflows/pr-code-format.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index f2bb37316d3a8b..fda5b6d96e78c2 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -2,6 +2,8 @@ name: "Check code formatting"
 
 permissions:
   contents: read
+  issues: write
+  pull-requests: write
 
 on:
   pull_request:



More information about the llvm-commits mailing list