Skip to content

Commit 15ade44

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

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/vrt2.yml

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

0 commit comments

Comments
 (0)