Skip to content

Commit 30aeef0

Browse files
committed
Temporarily change to PR for testing
Signed-off-by: Fanit Kolchina <[email protected]>
1 parent bd8b809 commit 30aeef0

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/check-for-issue.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: PR Checklist
1+
name: Check for issue for blogs
22

33
on:
44
pull_request:
55
types: [opened]
6+
paths:
7+
- '_posts/**'
68

79
permissions:
810
pull-requests: write
@@ -12,13 +14,28 @@ jobs:
1214
runs-on: ubuntu-latest
1315

1416
steps:
17+
- name: Check if PR adds new blog
18+
id: check-new-blog
19+
run: |
20+
files_added=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
21+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \
22+
| jq -r '.[] | select(.status == "added" and (.filename | startswith("_posts/"))) | .filename')
23+
24+
if [ ! -z "$files_added" ]; then
25+
echo "is_new_blog=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "is_new_blog=false" >> $GITHUB_OUTPUT
28+
fi
29+
1530
- name: Get PR body
31+
if: steps.check-new-blog.outputs.is_new_blog == 'true'
1632
id: pr-body
1733
run: |
1834
body="${{ github.event.pull_request.body }}"
1935
echo "body=${body}" >> $GITHUB_OUTPUT
2036
2137
- name: Check for linked issues
38+
if: steps.check-new-blog.outputs.is_new_blog == 'true'
2239
id: check-issues
2340
run: |
2441
body="${{ github.event.pull_request.body }}"
@@ -29,17 +46,17 @@ jobs:
2946
fi
3047
3148
- name: Comment if no linked issue
32-
if: steps.check-issues.outputs.has_issue == 'false'
49+
if: steps.check-new-blog.outputs.is_new_blog == 'true' && steps.check-issues.outputs.has_issue == 'false'
3350
uses: peter-evans/create-or-update-comment@v3
3451
with:
3552
token: ${{ secrets.GITHUB_TOKEN }}
3653
issue-number: ${{ github.event.pull_request.number }}
3754
body: |
3855
Hi @${{ github.event.pull_request.user.login }},
3956
40-
Looks like there is no issue linked in this PR. Please link this PR to an open issue using one of these keywords in the PR description:
57+
Looks like you're adding a new blog post and you don't have an issue mentioned. Please link this PR to an open issue using one of these keywords in the PR description:
4158
- Closes #issue-number
4259
- Fixes #issue-number
4360
- Resolves #issue-number
4461
45-
If there isn't an issue yet, please create one first and then link it to this PR.
62+
If there isn't an issue yet, please [create one](https://github.com/opensearch-project/project-website/issues/new?template=blog_post.yml) and then link it to this PR.

0 commit comments

Comments
 (0)