Skip to content

Commit c8a6d4d

Browse files
committed
Fix CI
Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 74da6a1 commit c8a6d4d

File tree

1 file changed

+22
-65
lines changed

1 file changed

+22
-65
lines changed

.github/workflows/module-monitor.yml

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Module Monitor
22
on:
3-
push:
4-
paths:
5-
- 'zephyr/module.yml'
63
pull_request_target:
74
paths:
85
- 'zephyr/module.yml'
@@ -24,7 +21,6 @@ jobs:
2421
persist-credentials: false
2522

2623
- name: Fetch PR head
27-
if: github.event_name == 'pull_request_target'
2824
run: |
2925
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-head
3026
@@ -44,25 +40,15 @@ jobs:
4440
GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha || '' }}
4541
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha || '' }}
4642
run: |
47-
# For pull requests, compare with base branch
48-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
49-
BASE_REF="$GITHUB_BASE_SHA"
50-
HEAD_REF="$GITHUB_HEAD_SHA"
51-
echo "DEBUG: Comparing $BASE_REF to $HEAD_REF" >&2
52-
echo "DEBUG: Current HEAD is $(git rev-parse HEAD)" >&2
53-
echo "DEBUG: Available commits:" >&2
54-
git log --oneline -5 >&2
55-
DIFF_OUTPUT=$(git diff $BASE_REF $HEAD_REF -- zephyr/module.yml || echo "No changes found")
56-
echo "DEBUG: Diff result: $DIFF_OUTPUT" >&2
57-
else
58-
# For push events, get the previous commit that modified module.yml
59-
PREV_COMMIT=$(git log --oneline --follow -- zephyr/module.yml | head -2 | tail -1 | cut -d' ' -f1)
60-
if [ -n "$PREV_COMMIT" ]; then
61-
DIFF_OUTPUT=$(git diff $PREV_COMMIT HEAD -- zephyr/module.yml || echo "No changes found")
62-
else
63-
DIFF_OUTPUT="No previous commit found for module.yml"
64-
fi
65-
fi
43+
# Compare with base branch for pull requests
44+
BASE_REF="$GITHUB_BASE_SHA"
45+
HEAD_REF="$GITHUB_HEAD_SHA"
46+
echo "DEBUG: Comparing $BASE_REF to $HEAD_REF" >&2
47+
echo "DEBUG: Current HEAD is $(git rev-parse HEAD)" >&2
48+
echo "DEBUG: Available commits:" >&2
49+
git log --oneline -5 >&2
50+
DIFF_OUTPUT=$(git diff $BASE_REF $HEAD_REF -- zephyr/module.yml || echo "No changes found")
51+
echo "DEBUG: Diff result: $DIFF_OUTPUT" >&2
6652
6753
echo "diff_output<<EOF" >> $GITHUB_OUTPUT
6854
echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT
@@ -104,8 +90,7 @@ jobs:
10490
print("EOF", file=sys.stdout)
10591
EOF
10692
107-
- name: Create or update comment (Pull Request)
108-
if: github.event_name == 'pull_request'
93+
- name: Create or update comment
10994
uses: actions/github-script@v7
11095
with:
11196
script: |
@@ -124,55 +109,27 @@ jobs:
124109
(process.env.blob_summary || '') + '\n\n' +
125110
'This comment was automatically generated.';
126111
127-
try {
128-
if (existingComment) {
129-
await github.rest.issues.updateComment({
130-
owner: context.repo.owner,
131-
repo: context.repo.repo,
132-
comment_id: existingComment.id,
133-
body: commentBody
134-
});
135-
} else {
136-
await github.rest.issues.createComment({
137-
owner: context.repo.owner,
138-
repo: context.repo.repo,
139-
issue_number: context.issue.number,
140-
body: commentBody
141-
});
142-
}
143-
} catch (error) {
144-
console.log('Could not create/update comment due to permissions. This is normal for forks.');
145-
console.log('Error:', error.message);
146-
}
147-
env:
148-
diff_output: ${{ steps.changes.outputs.diff_output }}
149-
blob_summary: ${{ steps.changes.outputs.blob_summary }}
150-
151-
- name: Create commit comment (Push)
152-
if: github.event_name == 'push'
153-
uses: actions/github-script@v7
154-
with:
155-
script: |
156-
const commentBody = 'Module Monitor\n\nChanges detected in module.yml\n\n' +
157-
(process.env.diff_output || 'No changes detected') + '\n\n' +
158-
(process.env.blob_summary || '') + '\n\n' +
159-
'This comment was automatically generated.';
160-
161-
try {
162-
await github.rest.repos.createCommitComment({
112+
if (existingComment) {
113+
await github.rest.issues.updateComment({
114+
owner: context.repo.owner,
115+
repo: context.repo.repo,
116+
comment_id: existingComment.id,
117+
body: commentBody
118+
});
119+
} else {
120+
await github.rest.issues.createComment({
163121
owner: context.repo.owner,
164122
repo: context.repo.repo,
165-
commit_sha: context.sha,
123+
issue_number: context.issue.number,
166124
body: commentBody
167125
});
168-
} catch (error) {
169-
console.log('Could not create commit comment due to permissions. This is normal for forks.');
170-
console.log('Error:', error.message);
171126
}
172127
env:
173128
diff_output: ${{ steps.changes.outputs.diff_output }}
174129
blob_summary: ${{ steps.changes.outputs.blob_summary }}
175130

131+
132+
176133
- name: Output summary
177134
run: |
178135
echo "## Module Monitor Summary" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)