File tree 1 file changed +62
-0
lines changed
1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : PR Image Comment
2
+
3
+ on :
4
+ pull_request :
5
+ types : [opened, synchronize]
6
+
7
+ jobs :
8
+ generate-image :
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - name : Checkout code
12
+ uses : actions/checkout@v4
13
+
14
+ - name : Install ImageMagick
15
+ run : sudo apt-get update && sudo apt-get install -y imagemagick
16
+
17
+ - name : Generate an image (example)
18
+ run : |
19
+ convert -size 100x100 xc:blue image.png # Example: create a 100x100 blue image
20
+
21
+ - name : Upload artifact
22
+ uses : actions/upload-artifact@v4
23
+ with :
24
+ name : pr-image
25
+ path : image.png
26
+
27
+ comment-with-image :
28
+ needs : generate-image
29
+ runs-on : ubuntu-latest
30
+ steps :
31
+ - name : Download artifact
32
+ uses : actions/download-artifact@v4
33
+ with :
34
+ name : pr-image
35
+ path : .
36
+
37
+ - name : Upload image to GitHub Issue
38
+ env :
39
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
40
+ run : |
41
+ UPLOAD_RESPONSE=$(gh api \
42
+ --method POST \
43
+ -H "Accept: application/vnd.github.v3+json" \
44
+
45
+ /repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments 2>&1) || true
46
+
47
+ echo "Upload response: $UPLOAD_RESPONSE"
48
+
49
+ IMG_URL=$(echo "$UPLOAD_RESPONSE" | jq -r '.url' 2>/dev/null || echo "")
50
+
51
+ if [[ -z "$IMG_URL" ]]; then
52
+ echo "Failed to extract image URL."
53
+ exit 1
54
+ fi
55
+
56
+ COMMENT_BODY="Here is the generated image: "
57
+
58
+ echo "Comment body: $COMMENT_BODY"
59
+
60
+ gh api --method POST /repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
61
+ -f body="$COMMENT_BODY"
62
+
You can’t perform that action at this time.
0 commit comments