-
-
Notifications
You must be signed in to change notification settings - Fork 623
706 lines (623 loc) · 25.2 KB
/
zwave-js-bot_comment.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
name: 'Z-Wave Bot: React to comments'
on:
issue_comment:
types: [created] # edited, deleted
jobs:
# Publish a PR build when an authorized person comments "@zwave-js-bot pack this"
publish-pr:
if: |
contains(github.event.issue.html_url, '/pull/') &&
contains(github.event.comment.body, '@zwave-js-bot pack this') &&
(github.event.comment.user.login == 'AlCalzone')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const options = {
owner: context.repo.owner,
repo: context.repo.repo,
};
const { data: pull } = await github.rest.pulls.get({
...options,
pull_number: context.payload.issue.number,
});
if (!pull.mergeable || !pull.merge_commit_sha) {
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `😥 Seems like this PR cannot be merged. Please fix the merge conflicts and try again.`,
});
process.exit(1);
}
await github.rest.issues.createComment({
...options,
issue_number: context.issue.number,
body: `👋 Hey @${context.payload.comment.user.login}!
I've started to deploy this PR as a development build.
You can monitor the progress [here](${context.payload.repository.html_url}/actions/runs/${context.runId}).`
})
- name: Checkout merged code
uses: actions/checkout@v4
with:
token: ${{secrets.BOT_TOKEN}}
fetch-depth: 0 # We need the history for versioning with yarn
ref: 'refs/pull/${{ github.event.issue.number }}/merge'
- name: Switch to a branch
run: git switch -c temp
- name: Prepare environment
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Publish PR build to npm
uses: actions/github-script@v7
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
github-token: ${{ secrets.BOT_TOKEN }}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.packPr({github, context});
# #########################################################################
# Fix lint errors when an authorized person posts "@zwave-js-bot fix lint"
fix-lint:
if: |
contains(github.event.issue.html_url, '/pull/') &&
contains(github.event.comment.body, '@zwave-js-bot fix lint') &&
(github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: trusted
- name: Check user's permissions to do this
id: check-permissions
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/trusted/.github/bot-scripts/index.js`);
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Retrieve PR information
if: steps.check-permissions.outputs.result == 'true'
id: pr-info
uses: actions/github-script@v7
with:
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/trusted/.github/bot-scripts/index.js`);
const result = await bot.getFixLintInfo({github, context});
console.dir(result);
return result || {pending: true};
- name: Download Lint patch
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.pr-info.outputs.result).pending
env:
PATCH_URL: ${{ fromJSON(steps.pr-info.outputs.result).patchUrl }}
run: |
mkdir -p patch
cd patch
curl "$PATCH_URL" -o patch.zip
unzip patch.zip
- name: Checkout pull request side by side
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.pr-info.outputs.result).pending
uses: actions/checkout@v4
with:
token: ${{secrets.BOT_TOKEN}}
repository: ${{ fromJSON(steps.pr-info.outputs.result).repoName }}
ref: ${{ fromJSON(steps.pr-info.outputs.result).headRef }}
path: untrusted
- name: Do the lint fix
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.pr-info.outputs.result).pending
working-directory: ./untrusted
id: fix
run: |
# Apply the patch
if ! git apply ../patch/fix.patch ; then
echo "result=error" >> $GITHUB_OUTPUT
exit 0
fi
# Check if something changed in the untrusted repo
cd ../untrusted
if ! git diff --quiet ; then
git config user.email "[email protected]"
git config user.name "Z-Wave JS Bot"
git add -A
git reset -- .github
git commit -m "style: fix lint"
git push
echo "result=ok" >> $GITHUB_OUTPUT
else
echo "result=unchanged" >> $GITHUB_OUTPUT
exit 0
fi
- name: Give feedback
if: steps.check-permissions.outputs.result == 'true'
uses: actions/github-script@v7
env:
FEEDBACK: ${{ steps.fix.outputs.result }}
PENDING: ${{ fromJSON(steps.pr-info.outputs.result).pending }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/trusted/.github/bot-scripts/index.js`);
return bot.fixLintFeedback({github, context});
# #########################################################################
# Rebase PR onto its target branch when an authorized person posts "@zwave-js-bot rebase"
rebase:
if: |
contains(github.event.issue.html_url, '/pull/') &&
contains(github.event.comment.body, '@zwave-js-bot rebase') &&
(github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout master branch
uses: actions/checkout@v4
- name: Check user's permissions to do this
id: check-permissions
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Retrieve PR information
if: steps.check-permissions.outputs.result == 'true'
uses: actions/github-script@v7
id: get-pr
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
}
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
try {
const result = await github.rest.pulls.get(request)
return result.data
} catch (err) {
core.setFailed(`Request failed with error ${err}`)
}
- name: Save our CI scripts
if: steps.check-permissions.outputs.result == 'true'
run: |
mkdir -p /tmp/.github
cp -r .github/* /tmp/.github
- name: Checkout pull request
if: steps.check-permissions.outputs.result == 'true'
uses: actions/checkout@v4
with:
token: ${{secrets.BOT_TOKEN}}
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
- name: Restore our CI scripts
if: steps.check-permissions.outputs.result == 'true'
run: |
rm -rf .github
cp -r /tmp/.github .
- name: Rebase the branch
env:
# sanitize untrusted input by using an env variable
BRANCH: ${{ fromJSON(steps.get-pr.outputs.result).base.ref }}
if: steps.check-permissions.outputs.result == 'true'
id: fix
run: |
# Try to rebase
git fetch origin
if git rebase "origin/$BRANCH" ; then
# The rebase worked
git config user.email "[email protected]"
git config user.name "Z-Wave JS Bot"
git push -f
else
echo "result=error" >> $GITHUB_OUTPUT
fi
- name: Give feedback
if: steps.check-permissions.outputs.result == 'true'
uses: actions/github-script@v7
env:
FEEDBACK: ${{ steps.fix.outputs.result }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.rebaseFeedback({github, context});
# No longer needed
# # #########################################################################
# # Rename the single commit of a PR to the title when an authorized person posts "@zwave-js-bot rename commit"
# rename-commit:
# if: |
# contains(github.event.issue.html_url, '/pull/') &&
# contains(github.event.comment.body, '@zwave-js-bot rename commit') &&
# (github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
# runs-on: [ubuntu-latest]
# strategy:
# matrix:
# node-version: [18] # This should be LTS
# steps:
# - name: Checkout master branch
# uses: actions/checkout@v4
# - name: Check permissions and necessity
# id: check-permissions
# uses: actions/github-script@v7
# with:
# github-token: ${{secrets.BOT_TOKEN}}
# result-encoding: string
# script: |
# const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
# return (
# (await bot.checkAuthorized({github, context})) &&
# (await bot.renameCommitCheck({github, context}))
# );
# # These steps only run if the check was successful
# - name: Retrieve PR information
# if: steps.check-permissions.outputs.result == 'true'
# uses: actions/github-script@v7
# id: get-pr
# with:
# script: |
# const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
# return bot.renameCommitGetPRInfo({github, context});
# - name: Save our CI scripts
# if: steps.check-permissions.outputs.result == 'true'
# run: |
# mkdir -p /tmp/.github
# cp -r .github/* /tmp/.github
# - name: Checkout pull request
# if: steps.check-permissions.outputs.result == 'true'
# uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Fetch the history, or this action will break everything!
# token: ${{secrets.BOT_TOKEN}}
# repository: ${{ fromJSON(steps.get-pr.outputs.result).repo }}
# ref: ${{ fromJSON(steps.get-pr.outputs.result).ref }}
# - name: Restore our CI scripts
# if: steps.check-permissions.outputs.result == 'true'
# run: |
# rm -rf .github
# cp -r /tmp/.github .
# - name: Rebase the branch
# env:
# # sanitize untrusted input by using an env variable
# TITLE: ${{ fromJSON(steps.get-pr.outputs.result).title }}
# if: steps.check-permissions.outputs.result == 'true'
# id: fix
# run: |
# # Try to reword the commit
# git config user.email "[email protected]"
# git config user.name "Z-Wave JS Bot"
# if git commit --amend -m "$TITLE" ; then
# # Amending the commit worked
# git push -f
# echo "result=success" >> $GITHUB_OUTPUT
# else
# echo "result=error" >> $GITHUB_OUTPUT
# fi
# - name: Give feedback
# if: steps.check-permissions.outputs.result == 'true'
# uses: actions/github-script@v7
# env:
# FEEDBACK: ${{ steps.fix.outputs.result }}
# with:
# github-token: ${{secrets.BOT_TOKEN}}
# script: |
# const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
# return bot.renameCommitFeedback({github, context});
# #########################################################################
# Imports a config file when an authorized person posts "@zwave-js-bot import config <device-id> from <source>"
import-config:
if: |
contains(github.event.issue.html_url, '/issues/') &&
contains(github.event.comment.body, '@zwave-js-bot import config') &&
(github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout master branch
uses: actions/checkout@v4
- name: Check user's permissions to do this
id: check-permissions
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Prepare environment
if: steps.check-permissions.outputs.result == 'true'
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
if: steps.check-permissions.outputs.result == 'true'
# We need this or the linter will complain about other stuff than the checks
run: yarn run build
- name: Get config file ID
if: steps.check-permissions.outputs.result == 'true'
id: config-id
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const body = context.payload.comment.body;
const match = /import config (?<ids>[a-z0-9_:, -]{1,}?) from (?<source>\w+)/.exec(body);
if (!match) return {skip: true};
return {
source: match.groups.source,
ids: match.groups.ids,
}
- name: Import config files
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.config-id.outputs.result).skip
id: import
env:
source: ${{ fromJSON(steps.config-id.outputs.result).source }}
ids: ${{ fromJSON(steps.config-id.outputs.result).ids }}
run: |
yarn run config import -s "$source" -Dd --ids "$ids"
branchname="import-config-$(date +'%s')"
commitmessage="feat(config): import config files from $source"
# Check if something changed
git config user.email "[email protected]"
git config user.name "Z-Wave JS Bot"
git checkout -b "$branchname"
git add -A
if ! git diff --quiet HEAD -- packages/config/config/devices/ ; then
git commit -m "$commitmessage"
git push --set-upstream origin "$branchname"
echo "result=success" >> $GITHUB_OUTPUT
echo "branchname=$branchname" >> $GITHUB_OUTPUT
echo "commitmessage=$commitmessage" >> $GITHUB_OUTPUT
else
echo "result=unchanged" >> $GITHUB_OUTPUT
exit 0
fi
- name: Create PR
if: steps.check-permissions.outputs.result == 'true'
uses: actions/github-script@v7
env:
RESULT: ${{ steps.import.outputs.result }}
branchname: ${{ steps.import.outputs.branchname }}
commitmessage: ${{ steps.import.outputs.commitmessage }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.importConfigCreatePR({github, context});
# #########################################################################
# Adds a compat flag to an existing file when an authorized person posts
# @zwave-js-bot add compat flag to <deviceId>
# ```
# mapBasicSet: "auto"
# ```
add-compat-flag:
if: |
contains(github.event.issue.html_url, '/issues/') &&
contains(github.event.comment.body, '@zwave-js-bot add compat flag') &&
(github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout master branch
uses: actions/checkout@v4
- name: Check user's permissions to do this
id: check-permissions
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Prepare environment
if: steps.check-permissions.outputs.result == 'true'
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
if: steps.check-permissions.outputs.result == 'true'
# We need this or the linter will complain about other stuff than the checks
run: yarn run build
- name: Parse command
if: steps.check-permissions.outputs.result == 'true'
id: parse-command
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const body = context.payload.comment.body;
const match1 = /add compat flag to `?(?<id>0x[0-9a-f]{4}:0x[0-9a-f]{4}:0x[0-9a-f]{4}(?::\d+\.\d+)?)`?\s/.exec(body);
const match2 = /```(?:jsonc?)?(?<flag>(?:.|\n|\r)*)```/.exec(body);
if (!match1 || !match2) return {skip: true};
return {
id: match1.groups.id,
flag: match2.groups.flag
}
- name: Add compat flag
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
uses: actions/github-script@v7
env:
id: ${{ fromJSON(steps.parse-command.outputs.result).id }}
flag: ${{ fromJSON(steps.parse-command.outputs.result).flag }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.addCompatFlag({github, context});
- name: Commit changes
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
id: commit-changes
env:
id: ${{ fromJSON(steps.parse-command.outputs.result).id }}
run: |
branchname="add-compat-flag-$(date +'%s')"
commitmessage="fix(config): add compat flag to $id"
# Check if something changed
git config user.email "[email protected]"
git config user.name "Z-Wave JS Bot"
git checkout -b "$branchname"
git add -A
if ! git diff --quiet HEAD -- packages/config/config/devices/ ; then
git commit -m "$commitmessage"
git push --set-upstream origin "$branchname"
echo "result=success" >> $GITHUB_OUTPUT
echo "branchname=$branchname" >> $GITHUB_OUTPUT
echo "commitmessage=$commitmessage" >> $GITHUB_OUTPUT
else
echo "result=unchanged" >> $GITHUB_OUTPUT
exit 0
fi
- name: Create PR
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
uses: actions/github-script@v7
env:
RESULT: ${{ steps.commit-changes.outputs.result }}
branchname: ${{ steps.commit-changes.outputs.branchname }}
commitmessage: ${{ steps.commit-changes.outputs.commitmessage }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.addCompatFlagCreatePR({github, context});
# #########################################################################
# Adds a fingerprint to an existing file when an authorized person posts
# @zwave-js-bot add fingerprint <newId> to <existingDeviceId>
add-fingerprint:
if: |
contains(github.event.issue.html_url, '/issues/') &&
contains(github.event.comment.body, '@zwave-js-bot add fingerprint') &&
(github.event.comment.user.login != 'zwave-js-bot' && github.event.comment.user.login != 'zwave-js-assistant[bot]')
runs-on: [ubuntu-latest]
strategy:
matrix:
node-version: [18] # This should be LTS
steps:
- name: Checkout master branch
uses: actions/checkout@v4
- name: Check user's permissions to do this
id: check-permissions
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
result-encoding: string
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Prepare environment
if: steps.check-permissions.outputs.result == 'true'
uses: ./.github/actions/prepare-env
with:
node-version: ${{ matrix.node-version }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Compile TypeScript code
if: steps.check-permissions.outputs.result == 'true'
# We need this or the linter will complain about other stuff than the checks
run: yarn run build
- name: Parse command
if: steps.check-permissions.outputs.result == 'true'
id: parse-command
uses: actions/github-script@v7
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const body = context.payload.comment.body;
const match = /add fingerprint `?(?<fingerprint>0x[0-9a-f]{4}:0x[0-9a-f]{4})`? to `?(?<id>0x[0-9a-f]{4}:0x[0-9a-f]{4}:0x[0-9a-f]{4}(?::\d+\.\d+)?)`?/.exec(body);
if (!match) return {skip: true};
return {
fingerprint: match.groups.fingerprint,
id: match.groups.id
}
- name: Add fingerprint
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
id: add-fingerprint
uses: actions/github-script@v7
env:
fingerprint: ${{ fromJSON(steps.parse-command.outputs.result).fingerprint }}
id: ${{ fromJSON(steps.parse-command.outputs.result).id }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.addFingerprint({github, context});
- name: Commit changes
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
id: commit-changes
env:
fingerprint: ${{ fromJSON(steps.parse-command.outputs.result).fingerprint }}
id: ${{ fromJSON(steps.parse-command.outputs.result).id }}
deviceLabel: ${{ steps.add-fingerprint.outputs.result }}
run: |
branchname="add-fingerprint-$(date +'%s')"
commitmessage="fix(config): add fingerprint \`$fingerprint\` to $deviceLabel"
# Check if something changed
git config user.email "[email protected]"
git config user.name "Z-Wave JS Bot"
git checkout -b "$branchname"
git add -A
if ! git diff --quiet HEAD -- packages/config/config/devices/ ; then
git commit -m "$commitmessage"
git push --set-upstream origin "$branchname"
echo "result=success" >> $GITHUB_OUTPUT
echo "branchname=$branchname" >> $GITHUB_OUTPUT
echo "commitmessage=$commitmessage" >> $GITHUB_OUTPUT
else
echo "result=unchanged" >> $GITHUB_OUTPUT
exit 0
fi
- name: Create PR
if: |
steps.check-permissions.outputs.result == 'true' &&
!fromJSON(steps.parse-command.outputs.result).skip
uses: actions/github-script@v7
env:
RESULT: ${{ steps.commit-changes.outputs.result }}
branchname: ${{ steps.commit-changes.outputs.branchname }}
commitmessage: ${{ steps.commit-changes.outputs.commitmessage }}
with:
github-token: ${{secrets.BOT_TOKEN}}
script: |
const bot = require(`${process.env.GITHUB_WORKSPACE}/.github/bot-scripts/index.js`);
return bot.addFingerprintCreatePR({github, context});