Skip to content

Commit 64aa18a

Browse files
authored
1 parent ab30fdb commit 64aa18a

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# A workflow to check if comment exists in PR description
16+
name: pr description check
17+
18+
on:
19+
pull_request:
20+
types: [opened, edited, reopened]
21+
22+
jobs:
23+
pr-description-check:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
pull-requests: read
27+
statuses: write
28+
contents: read
29+
if: "!contains(github.event.pull_request.title, '[bot]')"
30+
steps:
31+
- name: pr-description-check
32+
uses: NVIDIA/spark-rapids-common/pr-description-check@main
33+
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}

pr-description-check/action.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: 'PR Description Check'
16+
description: 'check if comment exists in PR description'
17+
inputs:
18+
github-token:
19+
description: "github token"
20+
required: true
21+
type: string
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Get PR description
27+
id: pr_description
28+
uses: actions/github-script@v7
29+
with:
30+
github-token: ${{ inputs.github-token }}
31+
script: |
32+
const pr = context.payload.pull_request;
33+
const prBody = pr.body || '';
34+
const sha = pr.head.sha;
35+
const hasComment = prBody.includes('<!--');
36+
const state = hasComment ? 'failure' : 'success';
37+
const description = hasComment
38+
? 'PR description contains comment in "<!--". Please remove the comment manually.'
39+
: 'PR description is valid.';
40+
41+
if (hasComment) {
42+
core.setFailed(description);
43+
}
44+
45+
await github.rest.repos.createCommitStatus({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
sha: sha,
49+
state: state,
50+
target_url: pr.html_url,
51+
description: description.substring(0, 140),
52+
context: 'PR Description'
53+
});

0 commit comments

Comments
 (0)