Skip to content

Commit dbe93f8

Browse files
committed
Modify the yml file
1 parent 6c18778 commit dbe93f8

1 file changed

Lines changed: 13 additions & 31 deletions

File tree

.github/workflows/gitcompare.yml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# .github/workflows/gitcompare.yml
22
name: GitCompare by Comment
33

4-
# 1) Trigger on any new issue or PR comment
54
on:
65
issue_comment:
76
types: [created]
87

98
jobs:
109
comment_trigger:
1110
runs-on: ubuntu-latest
12-
13-
# 2) Only run if the comment starts with "/gitcompare"
1411
if: startsWith(github.event.comment.body, '/gitcompare')
1512

1613
steps:
@@ -20,37 +17,22 @@ jobs:
2017
- name: Extract GOOD_BUILD and BAD_BUILD from comment
2118
id: parse_comment
2219
run: |
23-
COMMENT="$(printf '%s' "${{ github.event.comment.body }}")"
24-
25-
# Remove the first line ("/gitcompare")
26-
# Everything after that is either GOOD or BAD, separated by a line "—"
27-
BODY_AFTER_CMD="$(printf '%s\n' "$COMMENT" | tail -n +2)"
28-
29-
# Split into GOOD_BUILD (lines before the delimiter) and BAD_BUILD (lines after)
30-
GOOD_BUILD="$(printf '%s\n' "$BODY_AFTER_CMD" | sed -n '1,/^---$/p' | sed '1d')"
31-
BAD_BUILD="$(printf '%s\n' "$BODY_AFTER_CMD" | sed -n '1,/^---$/d')"
32-
33-
# Trim any leading/trailing blank lines (optional)
34-
GOOD_BUILD="$(printf '%s\n' "$GOOD_BUILD" | sed '/^[[:space:]]*$/d')"
35-
BAD_BUILD="$(printf '%s\n' "$BAD_BUILD" | sed '/^[[:space:]]*$/d')"
36-
37-
# Debug: Show what we parsed
38-
echo "Parsed GOOD_BUILD:"
39-
echo "----------"
40-
echo "$GOOD_BUILD"
41-
echo "----------"
42-
echo "Parsed BAD_BUILD:"
43-
echo "----------"
44-
echo "$BAD_BUILD"
45-
echo "----------"
46-
47-
# Export for next step
48-
echo "::set-output name=good::$GOOD_BUILD"
49-
echo "::set-output name=bad::$BAD_BUILD"
20+
COMMENT="${{ github.event.comment.body }}"
21+
BODY="$(printf '%s\n' "$COMMENT" | tail -n +2)"
22+
GOOD="$(printf '%s\n' "$BODY" | sed -n '1,/^---$/p' | sed '1d')"
23+
BAD="$(printf '%s\n' "$BODY" | sed -n '1,/^---$/d')"
24+
GOOD="$(printf '%s\n' "$GOOD" | sed '/^[[:space:]]*$/d')"
25+
BAD="$(printf '%s\n' "$BAD" | sed '/^[[:space:]]*$/d')"
26+
echo "GOOD_BUILD<<EOF" >> $GITHUB_ENV
27+
echo "$GOOD" >> $GITHUB_ENV
28+
echo "EOF" >> $GITHUB_ENV
29+
echo "BAD_BUILD<<EOF" >> $GITHUB_ENV
30+
echo "$BAD" >> $GITHUB_ENV
31+
echo "EOF" >> $GITHUB_ENV
5032
5133
- name: Make parsing script executable
5234
run: chmod +x .github/scripts/commit_hunter.sh
5335

5436
- name: Run commit_hunter.sh and print compare URLs
5537
run: |
56-
./.github/scripts/commit_hunter.sh "${{ steps.parse_comment.outputs.good }}" "${{ steps.parse_comment.outputs.bad }}"
38+
./.github/scripts/commit_hunter.sh "$GOOD_BUILD" "$BAD_BUILD"

0 commit comments

Comments
 (0)