Skip to content

Commit 37ba59b

Browse files
committed
hotfix: add gpu label on PR without merging
Signed-off-by: Akash Jaiswal <akashjaiswal3846@gmail.com>
1 parent 1a152fc commit 37ba59b

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

.github/workflows/request-gpu-runner-label.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ permissions:
66
contents: read
77

88
on:
9+
pull_request:
10+
types:
11+
- opened
12+
- reopened
13+
- labeled
14+
- synchronize
915
pull_request_target:
1016
types:
1117
- labeled
1218
- synchronize
1319

1420
concurrency:
15-
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
1622
cancel-in-progress: true
1723

1824
jobs:
1925
comment-if-missing-label:
26+
if: github.event_name == 'pull_request' || (github.event_name == 'pull_request_target' && github.actor != 'github-actions[bot]')
2027
runs-on: ubuntu-latest
28+
2129
steps:
2230
- name: Checkout PR branch
2331
uses: actions/checkout@v4
@@ -32,7 +40,7 @@ jobs:
3240
git fetch origin ${{ github.event.pull_request.head.sha }} --depth=1
3341
3442
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
35-
| grep -E '^examples/(deepspeed|torchtune)/'; then
43+
| grep -E '^examples/(deepspeed|torchtune)/' >/dev/null; then
3644
echo "found_changes=true" >> $GITHUB_OUTPUT
3745
else
3846
echo "found_changes=false" >> $GITHUB_OUTPUT
@@ -51,8 +59,24 @@ jobs:
5159
const hasLabel = labels.some(l => l.name === 'ok-to-test-gpu-runner');
5260
core.setOutput('has_label', hasLabel ? 'true' : 'false');
5361
62+
- name: Check if comment already exists
63+
id: comment-exists
64+
uses: actions/github-script@v7
65+
with:
66+
script: |
67+
const { data: comments } = await github.rest.issues.listComments({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
issue_number: context.issue.number
71+
});
72+
const botCommentExists = comments.some(c =>
73+
c.user.type === 'Bot' &&
74+
c.body.includes('ok-to-test-gpu-runner')
75+
);
76+
core.setOutput('exists', botCommentExists ? 'true' : 'false');
77+
5478
- name: Post comment requesting label
55-
if: steps.changes.outputs.found_changes == 'true' && steps.label-check.outputs.has_label == 'false'
79+
if: steps.changes.outputs.found_changes == 'true' && steps.label-check.outputs.has_label == 'false' && steps.comment-exists.outputs.exists == 'false'
5680
uses: actions/github-script@v7
5781
with:
5882
script: |
@@ -63,4 +87,4 @@ jobs:
6387
body: `Hello @andreyvelich @varodrig @jaiakash 👋,
6488
Changes were detected in the LLM blueprint directories (\`examples/deepspeed\` or \`examples/torchtune\`).
6589
To run the test on GPU infra, please add the **ok-to-test-gpu-runner** label to this PR.`
66-
});
90+
});

0 commit comments

Comments
 (0)