Skip to content

Commit 70b55cf

Browse files
committed
Do not comment on PRs
1 parent 5b8e4c2 commit 70b55cf

4 files changed

Lines changed: 21 additions & 39 deletions

File tree

.github/workflows/check-project-actions.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ jobs:
6565
runs-on: ubuntu-latest
6666
permissions:
6767
contents: read
68-
pull-requests: write
6968
steps:
7069
- name: "Checkout apache/infrastructure-actions"
7170
uses: actions/checkout@v2
@@ -92,10 +91,3 @@ jobs:
9291
9392
import check_repository_actions as c
9493
c.check_project_actions('./repository-to-be-checked', './approved_patterns.yml')
95-
96-
- name: Comment on PR
97-
if: failure() && github.event_name == 'pull_request'
98-
env:
99-
GH_TOKEN: ${{ github.token }}
100-
run:
101-
gh pr --repo ${{ github.repository }} comment ${{ github.event.pull_request.number }} --body-file step-summary-output.txt

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ jobs:
2727
permissions:
2828
# Only read access to the repository's content
2929
contents: read
30-
# Allow the workflow to add a comment to a PR in case the actions-verification failed
31-
pull-requests: write
3230
```
3331
3432
When calling the `check-project-actions` workflow from a `push` or `pull_request` event, it should work

check-actions-usage/sample-ci-workflow.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
paths:
3333
- ".github/**"
3434

35+
permissions:
36+
# Only read access is required.
37+
contents: read
38+
# All other permissions are "none".
39+
3540
jobs:
3641
# This is the job that verifies your project's usage of approved GitHub actions
3742
check:
@@ -40,9 +45,6 @@ jobs:
4045
permissions:
4146
# Only read access to the repository's content.
4247
contents: read
43-
# Allow the workflow to add a comment to a PR in case the actions-verification failed.
44-
# This is required to run the workflow.
45-
pull-requests: write
4648
# All other permissions are "none".
4749
# Optionally, you can specify a different repository and/or ref to check. These options are passed to
4850
# GitHub actions/checkout, see https://github.com/actions/checkout?tab=readme-ov-file#usage for details.

gateway/check_repository_actions.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -159,33 +159,23 @@ def check_project_actions(repository: str | os.PathLike, approved_patterns_file:
159159
failures.append(f"❌ {relative_path} {yaml_path}: '{uses_value}' is not approved")
160160

161161
if on_gha():
162-
summary_lines: list[str] = [
163-
"# GitHub Actions verification result",
164-
"",
165-
"For more information visit the [ASF Infrastructure GitHub Actions Policy](https://infra.apache.org/github-actions-policy.html) page",
166-
"and the [ASF Infrastructure Actions](https://github.com/apache/infrastructure-actions) repository.",
167-
]
168-
169-
if len(failures) > 0:
170-
summary_lines.extend(["", f"## Failures ({len(failures)})"])
171-
for msg in failures:
172-
summary_lines.extend([msg, ""])
173-
174-
if len(warnings) > 0:
175-
summary_lines.extend(["", f"## Warnings ({len(warnings)})"])
176-
for msg in warnings:
177-
summary_lines.extend([msg, ""])
178-
179-
if len(failures) == 0:
180-
summary_lines.append("✅ Success, all action usages match the currently approved patterns.")
181-
182-
summary_text = "\n".join(summary_lines).rstrip() + "\n"
183-
184162
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f:
185-
f.write(summary_text)
186-
# This file is used in the workflow to post a comment on a pull request.
187-
with open("step-summary-output.txt", "a") as f:
188-
f.write(summary_text)
163+
f.write(f"# GitHub Actions verification result\n")
164+
f.write("\n")
165+
f.write("For more information visit the [ASF Infrastructure GitHub Actions Policy](https://infra.apache.org/github-actions-policy.html) page\n")
166+
f.write("and the [ASF Infrastructure Actions](https://github.com/apache/infrastructure-actions) repository.\n")
167+
if len(failures) > 0:
168+
f.write("\n")
169+
f.write(f"## Failures ({len(failures)})\n")
170+
for msg in failures:
171+
f.write(f"{msg}\n\n")
172+
if len(warnings) > 0:
173+
f.write("\n")
174+
f.write(f"## Warnings ({len(warnings)})\n")
175+
for msg in warnings:
176+
f.write(f"{msg}\n\n")
177+
if len(failures) == 0:
178+
f.write(f"✅ Success, all action usages match the currently approved patterns.\n")
189179

190180
if len(failures) > 0:
191181
raise Exception(f"One or more action references are not approved or explicitly blocked:\n{"\n".join(failures)}")

0 commit comments

Comments
 (0)