Skip to content

Commit 0f606fe

Browse files
authored
Merge pull request #259 from Resgrid/develop
Develop
2 parents 713677c + 402f17b commit 0f606fe

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Sync PR to Changerawr
2+
permissions:
3+
contents: read
4+
issues: write
5+
6+
on:
7+
pull_request:
8+
types:
9+
- closed
10+
branches:
11+
- master
12+
13+
jobs:
14+
post-to-changerawr:
15+
# Only run if the PR was merged (not just closed)
16+
if: github.event.pull_request.merged == true
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Post to Changerawr API
21+
uses: actions/github-script@v7
22+
env:
23+
CHANGERAWR_API_KEY: ${{ secrets.CHANGERAWR_API_KEY }}
24+
CHANGERAWR_PROJECT_ID: ${{ secrets.CHANGERAWR_PROJECT_ID }}
25+
with:
26+
script: |
27+
const prBody = context.payload.pull_request.body || '';
28+
const prNumber = context.payload.pull_request.number;
29+
const prTitle = context.payload.pull_request.title;
30+
const prUrl = context.payload.pull_request.html_url;
31+
32+
// Prepare the payload for Changerawr API
33+
const payload = {
34+
notes: prBody,
35+
metadata: {
36+
pr_number: prNumber,
37+
pr_title: prTitle,
38+
pr_url: prUrl,
39+
merged_at: context.payload.pull_request.merged_at,
40+
merged_by: context.payload.pull_request.merged_by?.login || 'unknown'
41+
}
42+
};
43+
44+
try {
45+
const response = await fetch(
46+
`https://clog.resgrid.com/api/projects/${process.env.CHANGERAWR_PROJECT_ID}/changelog`,
47+
{
48+
method: 'POST',
49+
headers: {
50+
'Content-Type': 'application/json',
51+
'Authorization': `Bearer ${process.env.CHANGERAWR_API_KEY}`
52+
},
53+
body: JSON.stringify(payload)
54+
}
55+
);
56+
57+
if (!response.ok) {
58+
const errorText = await response.text();
59+
throw new Error(`Changerawr API request failed: ${response.status} - ${errorText}`);
60+
}
61+
62+
const result = await response.json();
63+
console.log('Successfully posted to Changerawr:', result);
64+
65+
// Optionally, comment on the PR with confirmation
66+
await github.rest.issues.createComment({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
issue_number: prNumber,
70+
body: '✅ Change notes have been posted to Changerawr.'
71+
});
72+
73+
} catch (error) {
74+
console.error('Error posting to Changerawr:', error);
75+
core.setFailed(`Failed to post to Changerawr: ${error.message}`);
76+
}

Core/Resgrid.Services/SubscriptionsService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ public async Task<DepartmentPlanCount> GetPlanCountsForDepartmentAsync(int depar
9999
var response = await client.ExecuteAsync<GetPlanCountsForDepartmentResult>(request);
100100

101101
if (response.StatusCode == HttpStatusCode.NotFound)
102-
return null;
102+
return new DepartmentPlanCount();
103103

104104
if (response.Data == null)
105-
return null;
105+
return new DepartmentPlanCount();
106106

107107
return response.Data.Data;
108108
}

Repositories/Resgrid.Repositories.NoSqlRepository/MongoRepository.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading.Tasks;
99
using Resgrid.Model;
1010
using Resgrid.Config;
11-
using System.Runtime.CompilerServices;
1211
using MongoDB.Driver.Linq;
1312

1413
namespace Resgrid.Repositories.NoSqlRepository

Web/Resgrid.Web.Services/Controllers/v4/MappingController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public async Task<ActionResult<GetMapDataResult>> GetMapDataAndMarkers()
102102
var callTypes = await _callsService.GetCallTypesForDepartmentAsync(DepartmentId);
103103

104104
var personnelStates = await _actionLogsService.GetLastActionLogsForDepartmentAsync(DepartmentId);
105-
var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId);
105+
//var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId);
106+
var people = await _usersService.GetUserGroupAndRolesByDepartmentIdAsync(DepartmentId, false, false, false);
106107
var personnelLocations = await _usersService.GetLatestLocationsForDepartmentPersonnelAsync(DepartmentId);
107108

108109
var personnelLocationTTL = await _departmentSettingsService.GetMappingPersonnelLocationTTLAsync(DepartmentId);
@@ -373,9 +374,9 @@ public async Task<ActionResult<GetMapDataResult>> GetMapDataAndMarkers()
373374
}
374375
}
375376

376-
if (personnelNames != null && personnelNames.Any())
377+
if (people != null && people.Any())
377378
{
378-
foreach (var person in personnelNames)
379+
foreach (var person in people)
379380
{
380381
if (!await _authorizationService.CanUserViewPersonLocationViaMatrixAsync(person.UserId, UserId, DepartmentId))
381382
continue;

0 commit comments

Comments
 (0)