-
-
Notifications
You must be signed in to change notification settings - Fork 76
Develop #259
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
Develop #259
Changes from all commits
0c3b08d
1aed9bf
8163810
402f17b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: Sync PR to Changerawr | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| post-to-changerawr: | ||
| # Only run if the PR was merged (not just closed) | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Post to Changerawr API | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| CHANGERAWR_API_KEY: ${{ secrets.CHANGERAWR_API_KEY }} | ||
| CHANGERAWR_PROJECT_ID: ${{ secrets.CHANGERAWR_PROJECT_ID }} | ||
| with: | ||
| script: | | ||
| const prBody = context.payload.pull_request.body || ''; | ||
| const prNumber = context.payload.pull_request.number; | ||
| const prTitle = context.payload.pull_request.title; | ||
| const prUrl = context.payload.pull_request.html_url; | ||
|
|
||
| // Prepare the payload for Changerawr API | ||
| const payload = { | ||
| notes: prBody, | ||
| metadata: { | ||
| pr_number: prNumber, | ||
| pr_title: prTitle, | ||
| pr_url: prUrl, | ||
| merged_at: context.payload.pull_request.merged_at, | ||
| merged_by: context.payload.pull_request.merged_by?.login || 'unknown' | ||
| } | ||
| }; | ||
|
|
||
| try { | ||
| const response = await fetch( | ||
| `https://clog.resgrid.com/api/projects/${process.env.CHANGERAWR_PROJECT_ID}/changelog`, | ||
| { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'Authorization': `Bearer ${process.env.CHANGERAWR_API_KEY}` | ||
| }, | ||
| body: JSON.stringify(payload) | ||
| } | ||
| ); | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text(); | ||
| throw new Error(`Changerawr API request failed: ${response.status} - ${errorText}`); | ||
| } | ||
|
|
||
| const result = await response.json(); | ||
| console.log('Successfully posted to Changerawr:', result); | ||
|
|
||
| // Optionally, comment on the PR with confirmation | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| body: '✅ Change notes have been posted to Changerawr.' | ||
| }); | ||
|
|
||
| } catch (error) { | ||
| console.error('Error posting to Changerawr:', error); | ||
| core.setFailed(`Failed to post to Changerawr: ${error.message}`); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,7 +102,8 @@ public async Task<ActionResult<GetMapDataResult>> GetMapDataAndMarkers() | |||||||
| var callTypes = await _callsService.GetCallTypesForDepartmentAsync(DepartmentId); | ||||||||
|
|
||||||||
| var personnelStates = await _actionLogsService.GetLastActionLogsForDepartmentAsync(DepartmentId); | ||||||||
| var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId); | ||||||||
| //var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId); | ||||||||
| var people = await _usersService.GetUserGroupAndRolesByDepartmentIdAsync(DepartmentId, false, false, false); | ||||||||
|
Comment on lines
+105
to
+106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove commented-out code. The commented-out line should be deleted rather than left in the codebase. Version control preserves the history if needed. Apply this diff:
- //var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId);
var people = await _usersService.GetUserGroupAndRolesByDepartmentIdAsync(DepartmentId, false, false, false);
var personnelLocations = await _usersService.GetLatestLocationsForDepartmentPersonnelAsync(DepartmentId);As per coding guidelines (avoid commented-out code). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| var personnelLocations = await _usersService.GetLatestLocationsForDepartmentPersonnelAsync(DepartmentId); | ||||||||
|
|
||||||||
| var personnelLocationTTL = await _departmentSettingsService.GetMappingPersonnelLocationTTLAsync(DepartmentId); | ||||||||
|
|
@@ -373,9 +374,9 @@ public async Task<ActionResult<GetMapDataResult>> GetMapDataAndMarkers() | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| if (personnelNames != null && personnelNames.Any()) | ||||||||
| if (people != null && people.Any()) | ||||||||
| { | ||||||||
| foreach (var person in personnelNames) | ||||||||
| foreach (var person in people) | ||||||||
| { | ||||||||
| if (!await _authorizationService.CanUserViewPersonLocationViaMatrixAsync(person.UserId, UserId, DepartmentId)) | ||||||||
| continue; | ||||||||
|
|
||||||||
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.
Add explicit permissions block for security.
The workflow should define explicit permissions for the GITHUB_TOKEN to follow the principle of least privilege. This prevents potential security issues if the workflow is modified in the future.
Apply this diff to add a minimal permissions block:
jobs: post-to-changerawr: # Only run if the PR was merged (not just closed) if: github.event.pull_request.merged == true runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read steps:Based on static analysis hints.
🤖 Prompt for AI Agents