Skip to content

Commit ba45c11

Browse files
committed
Update pr-publish.yml
1 parent 7438b4f commit ba45c11

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

.github/workflows/pr-publish.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,26 @@ jobs:
231231
if: steps.check-maintainer.outputs.approved == 'true'
232232
id: conflict-check
233233
run: |
234-
COMMENT_BODY="${{ github.event.comment.body }}"
234+
# Get the bot's comment that contains the codemod information
235+
# We need to find the bot's comment on this PR that contains "Ready to Publish Codemods"
236+
echo "Finding bot's comment with codemod information..."
237+
238+
# Get all comments on the PR
239+
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
240+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments")
241+
242+
# Find the bot's comment that contains "Ready to Publish Codemods"
243+
BOT_COMMENT=$(echo "$COMMENTS" | jq -r '.[] | select(.user.type == "Bot" and .body | contains("Ready to Publish Codemods")) | .body')
244+
245+
if [ -z "$BOT_COMMENT" ]; then
246+
echo "❌ Could not find bot's comment with codemod information"
247+
exit 1
248+
fi
249+
250+
echo "Found bot's comment, extracting codemod directories..."
235251
236-
# Extract codemod directories from the comment
237-
# First try to get from the "Changed codemods:" line
238-
CODEMODS=$(echo "$COMMENT_BODY" | grep "Changed codemods:" | sed 's/.*Changed codemods: *//' | sed 's/To publish.*//' | tr -d '`*' | tr ',' ' ' | xargs)
252+
# Extract codemod directories from the bot's comment
253+
CODEMODS=$(echo "$BOT_COMMENT" | grep "Changed codemods:" | sed 's/.*Changed codemods: *//' | sed 's/To publish.*//' | tr -d '`*' | tr ',' ' ' | xargs)
239254
240255
CONFLICTS_FOUND="false"
241256
FIXED_CONFLICTS=""
@@ -299,13 +314,25 @@ jobs:
299314
if: steps.check-maintainer.outputs.approved == 'true' && steps.conflict-check.outputs.conflicts-found == 'false'
300315
id: publish
301316
run: |
302-
COMMENT_BODY="${{ github.event.comment.body }}"
317+
# Get the bot's comment that contains the publish commands
318+
echo "Finding bot's comment with publish commands..."
319+
320+
# Get all comments on the PR
321+
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
322+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments")
323+
324+
# Find the bot's comment that contains "Ready to Publish Codemods"
325+
BOT_COMMENT=$(echo "$COMMENTS" | jq -r '.[] | select(.user.type == "Bot" and .body | contains("Ready to Publish Codemods")) | .body')
326+
327+
if [ -z "$BOT_COMMENT" ]; then
328+
echo "❌ Could not find bot's comment with publish commands"
329+
exit 1
330+
fi
303331
304-
# Extract commands from the comment
305-
echo "Extracting commands from comment..."
332+
echo "Found bot's comment, extracting commands..."
306333
307-
# Get the bash code block content
308-
COMMANDS=$(echo "$COMMENT_BODY" | sed -n '/```bash/,/```/p' | sed '1d;$d')
334+
# Get the bash code block content from the bot's comment
335+
COMMANDS=$(echo "$BOT_COMMENT" | sed -n '/```bash/,/```/p' | sed '1d;$d')
309336
310337
echo "Executing commands:"
311338
echo "$COMMANDS"

0 commit comments

Comments
 (0)