-
Notifications
You must be signed in to change notification settings - Fork 686
CI - Merge hooks #4224
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
base: master
Are you sure you want to change the base?
CI - Merge hooks #4224
Conversation
| owner: 'clockworklabs', | ||
| repo: 'SpacetimeDBPrivate', | ||
| workflow_id: 'public-pr-merge.yml', | ||
| ref: 'bfops/smarter-internal-tests', |
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.
before merging:
| ref: 'bfops/smarter-internal-tests', | |
| ref: 'master', |
|
|
||
| invokePrivate: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.merged == true |
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.
before merging:
| if: github.event.pull_request.merged == true | |
| if: github.event.pull_request.merged == true && | |
| github.event.pull_request.base.ref == 'master' |
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [ ] <!-- maybe a test you want to do --> - [ ] <!-- maybe a test you want a reviewer to do, so they can check it off when they're satisfied. --> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.merged == true | ||
| steps: | ||
| - name: Dispatch private merge workflow | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }} | ||
| script: | | ||
| await github.rest.actions.createWorkflowDispatch({ | ||
| owner: 'clockworklabs', | ||
| repo: 'SpacetimeDBPrivate', | ||
| workflow_id: 'public-pr-merge.yml', | ||
| ref: 'bfops/smarter-internal-tests', | ||
| inputs: { | ||
| public_pr_number: String(context.payload.pull_request.number), | ||
| } | ||
| }); |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
In general, the fix is to add an explicit permissions: block either at the workflow root (to apply to all jobs) or per job, granting only the scopes the workflow needs. Since this workflow appears to only need read access to repository contents and PR metadata via GITHUB_TOKEN, it can safely use contents: read at the workflow level as a minimal baseline. If in the future a job requires additional permissions, they can be added on that specific job.
The single best change here is: add a workflow-level permissions: block near the top of .github/workflows/discord-posts.yml, directly under the on: section, specifying contents: read. This will apply to both discordNotification and invokePrivate jobs. The invokePrivate job doesn’t use GITHUB_TOKEN at all (it uses secrets.SPACETIMEDB_PRIVATE_TOKEN), so it does not need additional permissions. No other functionality needs to change, and no imports or external libraries are required, since this is purely GitHub Actions YAML configuration.
Concretely:
- Edit
.github/workflows/discord-posts.yml. - After the
on: ...block (lines 3–5), insert:permissions: contents: read
- Leave the rest of the workflow unchanged. This explicitly limits the
GITHUB_TOKENto read-only access to repository contents and associated metadata, which is sufficient for runninggh pr checksand other read-only operations in this workflow.
-
Copy modified lines R7-R9
| @@ -4,6 +4,9 @@ | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| discordNotification: | ||
| runs-on: ubuntu-latest |
57e390f to
303b411
Compare
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [ ] <!-- maybe a test you want to do --> - [ ] <!-- maybe a test you want a reviewer to do, so they can check it off when they're satisfied. --> --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [ ] <!-- maybe a test you want to do --> - [ ] <!-- maybe a test you want a reviewer to do, so they can check it off when they're satisfied. --> --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [ ] <!-- maybe a test you want to do --> - [ ] <!-- maybe a test you want a reviewer to do, so they can check it off when they're satisfied. --> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
# Description of Changes <!-- Please describe your change, mention any related tickets, and so on here. --> # API and ABI breaking changes <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [ ] <!-- maybe a test you want to do --> - [ ] <!-- maybe a test you want a reviewer to do, so they can check it off when they're satisfied. --> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Description of Changes
Call a new workflow on PR merges.
API and ABI breaking changes
None. CI-only.
Expected complexity level and risk
2
Testing
Ask @bfops about testing.