Skip to content

Commit 0606982

Browse files
committed
ci(comment): convert workflow to action
No need to keep this level of isolation between these tasks. Signed-off-by: Randolph Sapp <rs@ti.com>
1 parent 827ae01 commit 0606982

5 files changed

Lines changed: 50 additions & 65 deletions

File tree

.github/actions/comment/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: "comment"
3+
description: "Comment on a given pull request or issue"
4+
inputs:
5+
token:
6+
description: "A token with pull request or issue write permission"
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Update pr with info from other runners
13+
uses: actions/github-script@v7
14+
with:
15+
github-token: ${{ inputs.token }}
16+
script: |
17+
var fs = require('fs');
18+
var issue_number = Number(fs.readFileSync('./results/id'));
19+
var problem_count = Number(fs.readFileSync(
20+
'./results/problem-count'
21+
));
22+
var summary = String(fs.readFileSync('./results/summary'));
23+
24+
if (problem_count > 0) {
25+
github.rest.issues.createComment({
26+
owner: context.repo.owner,
27+
issue_number: issue_number,
28+
repo: context.repo.repo,
29+
body: summary
30+
});
31+
}

.github/workflows/check-files.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
image: ghcr.io/texasinstruments/processor-sdk-doc:latest
2727
options: --entrypoint /bin/bash
2828

29+
permissions:
30+
pull-requests: write # Required to comment on pull requests
31+
2932
steps:
3033
- name: Checkout repository
3134
uses: actions/checkout@v4
@@ -40,6 +43,7 @@ jobs:
4043
git switch master
4144
4245
- name: Run check_files.py
46+
id: check
4347
env:
4448
EVENT_NUMBER: ${{ github.event.number }}
4549
run: |
@@ -69,10 +73,8 @@ jobs:
6973
# Exit with error if there are new warnings
7074
[ "$WARNING_COUNT" -eq "0" ]
7175
72-
- name: Save results
73-
uses: actions/upload-artifact@v4
76+
- name: Comment
77+
uses: ./.github/actions/comment
7478
if: always()
7579
with:
76-
name: results
77-
path: results/
78-
retention-days: 1
80+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/check_toc_txt.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
image: ghcr.io/texasinstruments/processor-sdk-doc:latest
2828
options: --entrypoint /bin/bash
2929

30+
permissions:
31+
pull-requests: write # Required to comment on pull requests
32+
3033
steps:
3134
- name: Checkout repository
3235
uses: actions/checkout@v4
@@ -70,10 +73,8 @@ jobs:
7073
# Exit with error if there are new warnings
7174
[ "$WARNING_COUNT" -eq "0" ]
7275
73-
- name: Save results
74-
uses: actions/upload-artifact@v4
76+
- name: Comment
77+
uses: ./.github/actions/comment
7578
if: always()
7679
with:
77-
name: results
78-
path: results/
79-
retention-days: 1
80+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/comment.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/rstcheck.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
image: ghcr.io/texasinstruments/processor-sdk-doc:latest
2727
options: --entrypoint /bin/bash
2828

29+
permissions:
30+
pull-requests: write # Required to comment on pull requests
31+
2932
steps:
3033
- name: Checkout repository
3134
uses: actions/checkout@v4
@@ -69,10 +72,8 @@ jobs:
6972
# Exit with error if there are new warnings
7073
[ "$WARNING_COUNT" -eq "0" ]
7174
72-
- name: Save results
73-
uses: actions/upload-artifact@v4
75+
- name: Comment
76+
uses: ./.github/actions/comment
7477
if: always()
7578
with:
76-
name: results
77-
path: results/
78-
retention-days: 1
79+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)