forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
R11DT-3590 Add Slack notification workflow for PR events #199
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: Slack Notification | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - ready_for_review | ||
| - opened | ||
| jobs: | ||
| slackNotification: | ||
| if: ${{ contains(fromJSON('["OS-miguelfreitas", "OS-joaomurgeiro", "osjlopes", "mvios", "OS-alexandretome", "rmb-guerra", "OS-rodrigolopes", "OS-thiagosiqueira", "OS-luisvendrame", "OS-josecunha"]'), github.event.pull_request.user.login) && !github.event.pull_request.draft }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: slackapi/slack-github-action@v2.0.0 | ||
| with: | ||
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| webhook-type: webhook-trigger | ||
| payload: | | ||
| pr_url: "${{ github.event.pull_request.html_url }}" | ||
| pr_number : "${{ github.event.pull_request.number }}" | ||
| pr_title: "${{ github.event.pull_request.title }}" | ||
| pr_user: "${{ github.event.pull_request.user.login }}" | ||
| pr_reviewers : "${{ join( github.event.pull_request.requested_reviewers.*.login , ' , ' ) }}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 6 months ago
In general, the fix is to add an explicit
permissions:block to the workflow (either at the root or at the job level) that grants only the minimal scopes required. This documents the intended access and prevents the workflow from gaining broader permissions if repository or organization defaults change or if the workflow is copied elsewhere.For this specific workflow in
.github/workflows/SlackNotification.yml, the job only reads PR data from the event payload and sends it to Slack via a secret webhook. It does not need to write to the repository, issues, or pull requests. The minimal sensible permissions arecontents: read,pull-requests: read, and optionallypackages: read(often included as part of a “read-only” baseline). We can set these at the workflow root so they apply to all jobs; since there is only one job (slackNotification), this is simple and does not alter behavior.Concretely: edit
.github/workflows/SlackNotification.ymland insert apermissions:section after thename:(or beforejobs:) at the top level:No additional imports, methods, or definitions are required; this is purely a YAML configuration change.