Skip to content

Commit cc76496

Browse files
Copilotcarstenartur
andcommitted
Address final code review issues: improve variable naming and error handling
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
1 parent 0206a7b commit cc76496

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

.github/workflows/sync-upstream.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838
# Create temporary directory for fork-specific files
3939
mkdir -p /tmp/fork-specific
4040
41-
# Get list of all files in fork
42-
ALL_FORK_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
41+
# Get list of all files in fork (filtering for fork-specific happens in the loop)
42+
ALL_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
4343
4444
# For each file in fork, check if it exists in upstream
45-
for file in $ALL_FORK_FILES; do
45+
for file in $ALL_FILES; do
4646
if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
4747
echo "Fork-specific file: $file"
4848
# Create directory structure and copy file
@@ -52,7 +52,7 @@ jobs:
5252
done
5353
5454
# Check if any fork-specific files were found
55-
if [ -d "/tmp/fork-specific" ] && [ "$(find /tmp/fork-specific -type f)" ]; then
55+
if [ -d "/tmp/fork-specific" ] && [ -n "$(find /tmp/fork-specific -type f)" ]; then
5656
echo "has_fork_files=true" >> $GITHUB_OUTPUT
5757
echo "Found fork-specific files:"
5858
find /tmp/fork-specific -type f
@@ -175,11 +175,11 @@ jobs:
175175
# Create temporary directory for fork-specific files
176176
mkdir -p /tmp/fork-specific
177177
178-
# Get list of all files in fork
179-
ALL_FORK_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
178+
# Get list of all files in fork (filtering for fork-specific happens in the loop)
179+
ALL_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
180180
181181
# For each file in fork, check if it exists in upstream
182-
for file in $ALL_FORK_FILES; do
182+
for file in $ALL_FILES; do
183183
if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
184184
echo "Fork-specific file: $file"
185185
# Create directory structure and copy file
@@ -189,7 +189,7 @@ jobs:
189189
done
190190
191191
# Check if any fork-specific files were found
192-
if [ -d "/tmp/fork-specific" ] && [ "$(find /tmp/fork-specific -type f)" ]; then
192+
if [ -d "/tmp/fork-specific" ] && [ -n "$(find /tmp/fork-specific -type f)" ]; then
193193
echo "has_fork_files=true" >> $GITHUB_OUTPUT
194194
echo "Found fork-specific files:"
195195
find /tmp/fork-specific -type f
@@ -241,32 +241,25 @@ jobs:
241241
uses: actions/github-script@v8
242242
with:
243243
script: |
244-
await github.rest.reactions.createForIssueComment({
244+
await github.rest.issues.createComment({
245245
owner: context.repo.owner,
246246
repo: context.repo.repo,
247-
comment_id: context.payload.comment.id,
248-
content: '+1'
247+
issue_number: context.issue.number,
248+
body: '✅ Successfully synced fork master with `eclipse-jdt/eclipse.jdt.debug:master`'
249249
});
250250
251-
await github.rest.issues.createComment({
251+
await github.rest.reactions.createForIssueComment({
252252
owner: context.repo.owner,
253253
repo: context.repo.repo,
254-
issue_number: context.issue.number,
255-
body: '✅ Successfully synced fork master with `eclipse-jdt/eclipse.jdt.debug:master`'
254+
comment_id: context.payload.comment.id,
255+
content: '+1'
256256
});
257257
258258
- name: Add failure comment
259259
if: steps.push.outputs.success == 'false'
260260
uses: actions/github-script@v8
261261
with:
262262
script: |
263-
await github.rest.reactions.createForIssueComment({
264-
owner: context.repo.owner,
265-
repo: context.repo.repo,
266-
comment_id: context.payload.comment.id,
267-
content: '-1'
268-
});
269-
270263
const comment = `❌ Sync failed. Please check the workflow logs for details.
271264
272265
[View workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId})`;
@@ -277,6 +270,13 @@ jobs:
277270
issue_number: context.issue.number,
278271
body: comment
279272
});
273+
274+
await github.rest.reactions.createForIssueComment({
275+
owner: context.repo.owner,
276+
repo: context.repo.repo,
277+
comment_id: context.payload.comment.id,
278+
content: '-1'
279+
});
280280
281281
- name: Fail workflow if push failed
282282
if: steps.push.outputs.success == 'false'

0 commit comments

Comments
 (0)