1111 permissions :
1212 contents : read
1313 issues : write
14+ pull-requests : write
1415 outputs :
1516 good_build : ${{ steps.parse.outputs.good_build }}
1617 bad_build : ${{ steps.parse.outputs.bad_build }}
3334 GOOD_BUILD=$(echo "$GOOD_BUILD" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
3435 BAD_BUILD=$(echo "$BAD_BUILD" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
3536
37+ echo "Good build: '$GOOD_BUILD'"
38+ echo "Bad build: '$BAD_BUILD'"
39+
3640 # Validate builds
3741 if [ -z "$GOOD_BUILD" ] || [ -z "$BAD_BUILD" ]; then
3842 echo "Error: Invalid format. Please provide both good and bad builds separated by ---"
5862 permissions :
5963 contents : read
6064 issues : write
65+ pull-requests : write
6166 steps :
6267 - name : Checkout repository
6368 uses : actions/checkout@v4
@@ -69,19 +74,37 @@ jobs:
6974 BAD_BUILD : ${{ needs.parse-comment.outputs.bad_build }}
7075 run : |
7176 cd CommitHunter
77+ echo "Running commit_hunter.sh with:"
78+ echo "Good build: $GOOD_BUILD"
79+ echo "Bad build: $BAD_BUILD"
7280 bash commit_hunter.sh "$GOOD_BUILD" "$BAD_BUILD" > output.txt
81+ echo "CommitHunter output:"
7382 cat output.txt
7483
7584 - name : Parse URLs from output
7685 id : parse_urls
7786 run : |
78- url_openj9=$(grep "OpenJ9:" output.txt | awk '{print $2}')
79- url_omr=$(grep "OMR:" output.txt | awk '{print $2}')
80- url_jcl=$(grep "JCL:" output.txt | awk '{print $2}')
81-
82- echo "url_openj9=$url_openj9" >> $GITHUB_OUTPUT
83- echo "url_omr=$url_omr" >> $GITHUB_OUTPUT
84- echo "url_jcl=$url_jcl" >> $GITHUB_OUTPUT
87+ if [ -f "./CommitHunter/output.txt" ]; then
88+ echo "Found output file, parsing URLs..."
89+ cat ./CommitHunter/output.txt
90+
91+ url_openj9=$(grep "OpenJ9:" ./CommitHunter/output.txt | awk '{print $2}')
92+ url_omr=$(grep "OMR:" ./CommitHunter/output.txt | awk '{print $2}')
93+ url_jcl=$(grep "JCL:" ./CommitHunter/output.txt | awk '{print $2}')
94+
95+ echo "Parsed URLs:"
96+ echo "OpenJ9: $url_openj9"
97+ echo "OMR: $url_omr"
98+ echo "JCL: $url_jcl"
99+
100+ echo "url_openj9=$url_openj9" >> $GITHUB_OUTPUT
101+ echo "url_omr=$url_omr" >> $GITHUB_OUTPUT
102+ echo "url_jcl=$url_jcl" >> $GITHUB_OUTPUT
103+ else
104+ echo "Error: output.txt not found in CommitHunter directory"
105+ ls -la ./CommitHunter/
106+ exit 1
107+ fi
85108
86109 - name : Prepare comment
87110 run : |
@@ -97,29 +120,39 @@ jobs:
97120 echo "${{ steps.parse_urls.outputs.url_jcl }}" >> comment.md
98121 echo "" >> comment.md
99122 echo "> 💡 **Note:** These links show the differences between the specified builds."
123+
124+ echo "Prepared comment:"
125+ cat comment.md
100126
101- - name : Set issue number env
102- run : echo "ISSUE_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
103-
104- - name : Comment on PR (Python)
127+ - name : Comment on PR
105128 env :
106129 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107130 GITHUB_REPOSITORY : ${{ github.repository }}
131+ ISSUE_NUMBER : ${{ github.event.issue.number }}
108132 run : |
109133 pip install PyGithub
110- python <<EOF
134+ python3 <<EOF
111135 import os
136+ import sys
112137 from github import Github
113-
114- with open("comment.md", "r", encoding="utf-8") as f:
115- comment_body = f.read()
116-
117- token = os.environ["GITHUB_TOKEN"]
118- repo_name = os.environ["GITHUB_REPOSITORY"]
119- issue_number = int(os.environ["ISSUE_NUMBER"])
120-
121- g = Github(token)
122- repo = g.get_repo(repo_name)
123- issue = repo.get_issue(number=issue_number)
124- issue.create_comment(comment_body)
138+
139+ try:
140+ with open("comment.md", "r", encoding="utf-8") as f:
141+ comment_body = f.read()
142+
143+ token = os.environ["GITHUB_TOKEN"]
144+ repo_name = os.environ["GITHUB_REPOSITORY"]
145+ issue_number = int(os.environ["ISSUE_NUMBER"])
146+
147+ g = Github(token)
148+ repo = g.get_repo(repo_name)
149+ issue = repo.get_issue(number=issue_number)
150+
151+ comment = issue.create_comment(comment_body)
152+ print(f"✅ Comment created successfully: {comment.html_url}")
153+
154+ except Exception as e:
155+ print(f"❌ Error creating comment: {e}")
156+ print(f"Error type: {type(e).__name__}")
157+ sys.exit(1)
125158 EOF
0 commit comments