-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github/workflows: set read-only default permissions to approve workflow #18368
github/workflows: set read-only default permissions to approve workflow #18368
Conversation
Signed-off-by: Ivan Valdes <[email protected]>
94bffec
to
5a02298
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. We cannot change status of CI without having write permissions.
Context: #15659
The problem: https://github.com/orgs/community/discussions/49688
@@ -1,5 +1,6 @@ | |||
--- | |||
name: Approve GitHub Workflows | |||
permissions: read-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably something like below?
permissions:
actions:write
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should work! Thanks, I forgot that the issue is about the default permission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was initially going to set it with explicit permission at the top of the file. However, I based this implementation on other workflows. For example, the scorecard workflow declares the read-all
permission at the top of the file:
etcd/.github/workflows/scorecards.yml
Lines 11 to 12 in f00ceb6
# Declare default permissions as read only. | |
permissions: read-all |
Then, in the job, sets the write permissions:
etcd/.github/workflows/scorecards.yml
Lines 18 to 22 in f00ceb6
permissions: | |
# Needed to upload the results to code-scanning dashboard. | |
security-events: write | |
# Used to receive a badge. | |
id-token: write |
I tested it on my fork, and seems to work fine: https://github.com/ivanvc/etcd/actions/runs/10115486985/job/27976358983?pr=210
Let me know if you still want me to change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just realised that you already added at the job level,
permissions:
actions:write
Looks good to me.
This PR should be good to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Thanks @ivanvc
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, fuweid, ivanvc, jmhbnz, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
As discovered by the OpenSSF Scorecard, the
gh-workflow-approve.yaml
action didn't specify default permissions. This pull request fixes that issue.Part of #18362.
Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.