Skip to content

Commit efa9aa8

Browse files
committed
add support for all tools, post a different comments if no doc was generated
1 parent 404e04e commit efa9aa8

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

.github/workflows/generate-go-docs.yaml

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ on:
99

1010
jobs:
1111
generate_docs_new_pr:
12-
if: ${{ contains(github.event.pull_request.labels.*.name, 'generate_go_docs') }}
12+
if: ${{ contains(github.event.pull_request.labels.*.name, 'generate_go_docs') }}
1313
runs-on: ubuntu-latest
1414
environment: integration
1515
permissions:
1616
id-token: write
17-
contents: read
17+
contents: read
1818

1919
steps:
2020
- name: Setup GitHub Token for reading Generate Go Doc Repo
@@ -56,18 +56,38 @@ jobs:
5656
- 'k8s-test-runner/**/*.go'
5757
framework:
5858
- 'framework/**/*.go'
59+
tools/asciitable:
60+
- 'tools/asciitable/**/*.go'
61+
tools/breakingchanges:
62+
- 'tools/breakingchanges/**/*.go'
63+
tools/citool:
64+
- 'tools/citool/**/*.go'
65+
tools/ecrimagefetcher:
66+
- 'tools/ecrimagefetcher/**/*.go'
67+
tools/envresolve:
68+
- 'tools/envresolve/**/*.go'
5969
tools/flakeguard:
60-
- 'tools/flakeguard/**/*.go'
61-
# later add tools here or, if possible, make this filter dynamic so that it's created based on the go modules in the repository
70+
- 'tools/flakeguard/**/*.go'
71+
tools/ghlatestreleasechecker:
72+
- 'tools/ghlatestreleasechecker/**/*.go'
73+
tools/ghsecrets:
74+
- 'tools/ghsecrets/**/*.go'
75+
tools/gotestloghelper:
76+
- 'tools/gotestloghelper/**/*.go'
77+
tools/testlistgenerator:
78+
- 'tools/testlistgenerator/**/*.go'
79+
tools/workflowresultparser:
80+
- 'tools/workflowresultparser/**/*.go'
81+
# add more projects here
6282
6383
- name: Find all go modules in the repository and filter the ones that changed
6484
shell: bash
6585
id: go-modules
6686
env:
67-
FILTERS: ${{ steps.changes.outputs.changes }}
87+
FILTERS: ${{ steps.changes.outputs.changes }}
6888
run: |
6989
PATH=$PATH:$(go env GOPATH)/bin
70-
export PATH
90+
export PATH
7191
7292
# Find all go projects
7393
gomods_output=$(gomods 2>&1)
@@ -117,7 +137,7 @@ jobs:
117137
with:
118138
aws-role-arn: ${{ secrets.AWS_ROLE_ARN_CREATE_PR }}
119139
aws-lambda-url: ${{ secrets.GATI_LAMBDA_TT_URL }}
120-
aws-region: ${{ secrets.AWS_REGION }}
140+
aws-region: ${{ secrets.AWS_REGION }}
121141

122142
- name: Create a new PR targeting current PR
123143
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
@@ -130,26 +150,45 @@ jobs:
130150
body: "This PR contains automatically generated go documentation for the PR#${{ github.event.pull_request.number }}. Please review the changes."
131151
commit-message: "[Bot] Add automatically generated go documentation"
132152

153+
- name: Check outputs
154+
run: |
155+
echo "new: ${{ steps.create-pr.outputs.pull-request-number }}"
156+
echo "old: ${{ github.event.pull_request.number }}"
157+
133158
- name: Find comment with PR link
134159
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
135160
id: fc
136161
with:
137162
issue-number: ${{ github.event.pull_request.number }}
138163
body-includes: Go doc generation
139164

140-
- name: Create comment in the original PR
165+
- name: Create comment in the original PR with link to the new PR
141166
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
142-
if: steps.fc.outputs.comment-id == 0
167+
if: steps.create-pr.outputs.pull-request-number != ''
143168
with:
144169
token: ${{ steps.setup-github-token-write.outputs.access-token }}
145170
issue-number: ${{ github.event.pull_request.number }}
171+
comment-id: ${{ steps.fc.outputs.comment-id }}
172+
edit-mode: replace
146173
body: |
147174
## Go doc generation
148175
Hey @${{ github.actor }}, you can check generated Go function documentation [here](${{ steps.create-pr.outputs.pull-request-url }}). Please review them and merge to this PR once you're satisfied with them.
149176
177+
- name: Create comment in the original PR to notify about no new docs
178+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
179+
if: steps.create-pr.outputs.pull-request-number == ''
180+
with:
181+
token: ${{ steps.setup-github-token-write.outputs.access-token }}
182+
issue-number: ${{ github.event.pull_request.number }}
183+
comment-id: ${{ steps.fc.outputs.comment-id }}
184+
edit-mode: replace
185+
body: |
186+
## Go doc generation
187+
Hey @${{ github.actor }}, no documentation was generated. Are you sure that you made changes to public functions without existing comments in your PR?
188+
150189
- name: Send Slack notification
151190
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
152-
if: failure()
191+
if: failure()
153192
id: slack
154193
env:
155194
SLACK_BOT_TOKEN: ${{ secrets.QA_SLACK_API_KEY }}
@@ -174,7 +213,7 @@ jobs:
174213
"type": "mrkdwn",
175214
"text": "<@U060CGGPY8H>, please have a look."
176215
}
177-
},
216+
},
178217
{
179218
"type": "section",
180219
"text": {

0 commit comments

Comments
 (0)