-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomstuff_comment
More file actions
44 lines (36 loc) · 1.26 KB
/
randomstuff_comment
File metadata and controls
44 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Random Number Commenter
on:
issues:
types: [labeled]
jobs:
run_random_script:
runs-on: ubuntu-latest
steps:
- name: Check for 'gemma' label and generate numbers
id: randomizer
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const label = context.payload.label.name;
if (label.toLowerCase() !== "gemma") {
console.log(`Label '${label}' is not 'gemma'. Skipping.`);
return "SKIP";
}
const numbers = Array.from({ length: 5 }, () => Math.floor(Math.random() * 100));
console.log("🎲 Generated numbers:", numbers.join(", "));
return numbers.join(", ");
- name: Post comment with numbers
if: steps.randomizer.outputs.result != 'SKIP'
uses: actions/github-script@v7
with:
script: |
const issue_number = context.issue.number;
const numbers = `${{ steps.randomizer.outputs.result }}`;
const comment = `🎲 Random numbers generated by GitHub Actions: **${numbers}**`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
body: comment
});