Skip to content

Commit 1c99466

Browse files
committed
test: wip: comment under pr
1 parent e9173b7 commit 1c99466

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/vrt2.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: comment image under PR
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+
18+
- name: Generate an image (example)
19+
run: |
20+
convert -size 100x100 xc:blue image.png
21+
22+
- name: Upload artifact
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: pr-image
26+
path: image.png
27+
28+
comment-with-image:
29+
needs: generate-image
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Download artifact
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: pr-image
36+
path: .
37+
38+
- name: Upload image to GitHub Issue
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
IMG_URL=$(gh api \
43+
--method POST \
44+
-H "Accept: application/vnd.github.v3+json" \
45+
-F "file=@image.png" \
46+
/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments)
47+
48+
COMMENT_URL=$(echo $IMG_URL | jq -r .url)
49+
50+
gh api --method POST /repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
51+
-f body="Here is the generated image: ![Artifact Image]($COMMENT_URL)"
52+

0 commit comments

Comments
 (0)