Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 110 additions & 15 deletions .github/workflows/changerawr-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
permissions:
contents: read
issues: write
pull-requests: read

on:
pull_request:
Expand All @@ -17,30 +18,111 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: Extract and prepare release notes
id: prepare_notes
env:
GH_TOKEN: ${{ github.token }}
run: |
set -eo pipefail

# Function to extract release notes from PR body
extract_release_notes() {
local body="$1"

# Remove "Summary by CodeRabbit" section and auto-generated comment line
local cleaned_body="$(printf '%s\n' "$body" \
| grep -v '<!-- end of auto-generated comment: release notes by coderabbit.ai -->' \
| awk '
BEGIN { skip=0 }
/^## Summary by CodeRabbit/ { skip=1; next }
/^## / && skip==1 { skip=0 }
skip==0 { print }
')"

# Try to extract content under "## Release Notes" heading
local notes="$(printf '%s\n' "$cleaned_body" \
| awk 'f && /^## /{exit} /^## Release Notes/{f=1; next} f')"

# If no specific section found, use the entire cleaned body
if [ -z "$notes" ]; then
notes="$cleaned_body"
fi

printf '%s\n' "$notes"
}

echo "Fetching PR #${{ github.event.pull_request.number }} details..."

# Fetch the PR body using GitHub CLI
PR_BODY=$(gh pr view "${{ github.event.pull_request.number }}" --json body --jq '.body' 2>/dev/null || echo "")

NOTES=""
if [ -n "$PR_BODY" ]; then
echo "PR body found, extracting release notes..."
NOTES="$(extract_release_notes "$PR_BODY")"
fi

# Fallback to PR title and recent commits if no body found
if [ -z "$NOTES" ] || [ "$NOTES" = "" ]; then
echo "No PR body found, using PR title and commits..."
NOTES="## ${{ github.event.pull_request.title }}"
NOTES="$NOTES"$'\n\n'"$(git log -n 5 --pretty=format:'- %s')"
fi

# Save to file and environment
echo "$NOTES" > release_notes.txt

# For multiline output, use delimiter
{
echo 'RELEASE_NOTES<<EOF'
echo "$NOTES"
echo 'EOF'
} >> "$GITHUB_OUTPUT"

echo "Release notes prepared:"
cat release_notes.txt

- 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 }}
RELEASE_NOTES: ${{ steps.prepare_notes.outputs.RELEASE_NOTES }}
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;
const releaseNotes = process.env.RELEASE_NOTES || '';

// Check if required secrets are set
if (!process.env.CHANGERAWR_API_KEY || !process.env.CHANGERAWR_PROJECT_ID) {
console.log('⚠️ Changerawr API credentials not configured, skipping release notes submission');
return;
}

// Prepare the payload for Changerawr API
const payload = {
notes: prBody,
title: prTitle,
content: releaseNotes,
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'
merged_by: context.payload.pull_request.merged_by?.login || 'unknown',
commit_sha: context.payload.pull_request.merge_commit_sha
}
};

console.log('Sending release notes to Changerawr...');
console.log('Payload:', JSON.stringify(payload, null, 2));

try {
const response = await fetch(
`https://clog.resgrid.com/api/projects/${process.env.CHANGERAWR_PROJECT_ID}/changelog`,
Expand All @@ -54,23 +136,36 @@ jobs:
}
);

const responseText = await response.text();

if (!response.ok) {
const errorText = await response.text();
throw new Error(`Changerawr API request failed: ${response.status} - ${errorText}`);
console.warn(`⚠️ Changerawr API request failed: ${response.status} - ${responseText}`);
// Don't fail the workflow, just log the error
return;
}

const result = await response.json();
console.log('Successfully posted to Changerawr:', result);
let result;
try {
result = JSON.parse(responseText);
} catch (e) {
result = responseText;
}

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.'
});
try {
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 (commentError) {
console.log('Could not post comment to PR:', commentError.message);
}

} catch (error) {
console.error('Error posting to Changerawr:', error);
core.setFailed(`Failed to post to Changerawr: ${error.message}`);
console.error('⚠️ Error posting to Changerawr:', error);
// Don't fail the workflow
}
11 changes: 3 additions & 8 deletions Core/Resgrid.Services/PushService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using DnsClient;
using FirebaseAdmin.Messaging;
using Resgrid.Model;
using Resgrid.Model;
using Resgrid.Model.Messages;
using Resgrid.Model.Providers;
using Resgrid.Model.Services;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

Expand Down Expand Up @@ -113,7 +108,7 @@ public async Task<bool> PushMessage(StandardPushMessage message, string userId,
try
{
if (!string.IsNullOrWhiteSpace(message.DepartmentCode))
await _novuProvider.SendUserMessage(message.Title, message.SubTitle, userId, message.DepartmentCode, string.Format("M{0}", message.MessageId), null);
await _novuProvider.SendUserMessage(message.Title, message.SubTitle, userId, message.DepartmentCode, string.Format("M{0}", message.MessageId), ((int)PushSoundTypes.Message).ToString());
}
catch (Exception ex)
{
Expand Down Expand Up @@ -145,7 +140,7 @@ public async Task<bool> PushNotification(StandardPushMessage message, string use
try
{
if (!string.IsNullOrWhiteSpace(message.DepartmentCode))
await _novuProvider.SendUserNotification(message.Title, message.SubTitle, userId, message.DepartmentCode, string.Format("N{0}", message.MessageId), null);
await _novuProvider.SendUserNotification(message.Title, message.SubTitle, userId, message.DepartmentCode, string.Format("N{0}", message.MessageId), ((int)PushSoundTypes.Notifiation).ToString());
}
catch (Exception ex)
{
Expand Down
1 change: 0 additions & 1 deletion Core/Resgrid.Services/Resgrid.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Bus\Resgrid.Providers.Bus.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Cache\Resgrid.Providers.Cache.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Email\Resgrid.Providers.Email.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Firebase\Resgrid.Providers.Firebase.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Geo\Resgrid.Providers.Geo.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Marketing\Resgrid.Providers.Marketing.csproj" />
<ProjectReference Include="..\..\Providers\Resgrid.Providers.Number\Resgrid.Providers.Number.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
<ProjectReference Include="..\..\Core\Resgrid.Framework\Resgrid.Framework.csproj" />
<ProjectReference Include="..\..\Core\Resgrid.Model\Resgrid.Model.csproj" />
<ProjectReference Include="..\Resgrid.Providers.Bus\Resgrid.Providers.Bus.csproj" />
<ProjectReference Include="..\Resgrid.Providers.Firebase\Resgrid.Providers.Firebase.csproj" />
</ItemGroup>
</Project>
59 changes: 0 additions & 59 deletions Providers/Resgrid.Providers.Firebase/FirebaseAuthProvider.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Providers/Resgrid.Providers.Firebase/FirebaseProviderModule.cs

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions Providers/Resgrid.Providers.Firebase/app.config

This file was deleted.

10 changes: 0 additions & 10 deletions Providers/Resgrid.Providers.Firebase/packages.config

This file was deleted.

Loading
Loading