1919 with :
2020 fetch-depth : 0
2121 persist-credentials : false
22+ ref : ${{ github.event.pull_request.head.sha }}
2223
2324 - name : Fetch PR head
2425 run : |
5051
5152 # Get old and new module.yml content
5253 git show $BASE_REF:zephyr/module.yml > old_module.yml
53- cp zephyr/module.yml new_module.yml
54+ git show $HEAD_REF: zephyr/module.yml > new_module.yml
5455
5556 # Parse YAML and generate comparison table
5657 python3 << 'EOF'
@@ -72,20 +73,15 @@ jobs:
7273 return commit_part[:7]
7374 return "Unknown"
7475
75- def generate_diff_link(url ):
76+ def generate_diff_link(old_url, new_url ):
7677 """Generate diff link for the source repository"""
77- if 'github.com' in url and 'raw/' in url:
78- # Convert raw URL to repository URL
79- repo_url = url.replace('/raw/', '/blob/')
80- # Extract commit and path
81- if '/raw/' in url:
82- parts = url.split('/raw/')
83- if len(parts) > 1:
84- commit_path = parts[1]
85- commit = commit_path.split('/')[0]
86- path = '/'.join(commit_path.split('/')[1:])
87- # Create diff link (this would need to be updated with actual previous commit)
88- return f"https://github.com/nrfconnect/sdk-nrfxlib/compare/{commit}...{commit}"
78+ old_commit = extract_commit_from_url(old_url)
79+ new_commit = extract_commit_from_url(new_url)
80+
81+ if old_commit != "Unknown" and new_commit != "Unknown" and old_commit != new_commit:
82+ return f"https://github.com/nrfconnect/sdk-nrfxlib/compare/{old_commit}...{new_commit}"
83+ elif new_commit != "Unknown":
84+ return f"https://github.com/nrfconnect/sdk-nrfxlib/commit/{new_commit}"
8985 return "N/A"
9086
9187 try:
@@ -115,19 +111,39 @@ jobs:
115111 new_sha = new_blob.get('sha256', 'N/A')[:16] + '...' if new_blob.get('sha256') else 'N/A'
116112 old_commit = extract_commit_from_url(old_blob.get('url', ''))
117113 new_commit = extract_commit_from_url(new_blob.get('url', ''))
118- diff_link = generate_diff_link(new_blob.get('url', ''))
114+ diff_link = generate_diff_link(old_blob.get('url', ''), new_blob.get('url', ''))
119115
120116 # Extract variant name from path
121117 variant = path.split('/')[-2] if '/' in path else path
122118
123119 table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_sha} | {new_sha} | {old_commit} | {new_commit} | {diff_link} |")
124120
121+ # Check if there are any actual changes
122+ has_changes = False
123+ for path in sorted(all_paths):
124+ old_blob = old_blobs.get(path, {})
125+ new_blob = new_blobs.get(path, {})
126+ if (old_blob.get('version') != new_blob.get('version') or
127+ old_blob.get('sha256') != new_blob.get('sha256') or
128+ old_blob.get('url') != new_blob.get('url')):
129+ has_changes = True
130+ break
131+
125132 # Output the table
126133 print("diff_output<<EOF", file=sys.stdout)
127- print("## Firmware Blob Changes", file=sys.stdout)
128- print("", file=sys.stdout)
129- for row in table_rows:
130- print(row, file=sys.stdout)
134+ if has_changes:
135+ print("## Firmware Blob Changes", file=sys.stdout)
136+ print("", file=sys.stdout)
137+ for row in table_rows:
138+ print(row, file=sys.stdout)
139+ else:
140+ print("## No Changes Detected", file=sys.stdout)
141+ print("", file=sys.stdout)
142+ print("All firmware blobs remain unchanged in this PR.", file=sys.stdout)
143+ print("", file=sys.stdout)
144+ print("### Current Firmware Blob Summary:", file=sys.stdout)
145+ for row in table_rows[2:]: # Skip header rows
146+ print(row, file=sys.stdout)
131147 print("EOF", file=sys.stdout)
132148
133149 # Also output current blob summary
@@ -169,6 +185,9 @@ jobs:
169185 comment.body.includes('Module Monitor')
170186 );
171187
188+ console.log('DEBUG: diff_output length:', process.env.diff_output ? process.env.diff_output.length : 0);
189+ console.log('DEBUG: blob_summary length:', process.env.blob_summary ? process.env.blob_summary.length : 0);
190+
172191 const commentBody = 'Module Monitor\n\nChanges detected in module.yml\n\n' +
173192 (process.env.diff_output || 'No changes detected') + '\n\n' +
174193 (process.env.blob_summary || '') + '\n\n' +
0 commit comments