-
Notifications
You must be signed in to change notification settings - Fork 16
75 lines (69 loc) · 2.79 KB
/
govulncheck-cron-schedule.yaml
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
# "Govulncheck reports known vulnerabilities that affect Go code.
# It uses static analysis of source code or a binary's symbol table to narrow down reports to only those that could affect the application."
#
# For more information see https://go.dev/blog/vuln and https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck
name: 'Scheduled govulncheck'
on:
# run schedule every work day at 9:42 UTC
schedule:
- cron: '42 9 * * 1-5'
# allow manually triggering workflow
workflow_dispatch:
jobs:
govulncheck_job:
runs-on: ubuntu-latest
name: Run govulncheck
strategy:
fail-fast: false
matrix:
# CodeQL runs on these branches. Pattern matching doesn't work, so we need to add relevant branches manually.
branches:
- 'master'
- 'V5.4'
- 'V6.0'
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ matrix.branches }}
- name: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: '' # remove default to suppress github warning
go-version-file: 'go.mod' # test against go.mod since 'stable' is not valid for older branches
go-package: ./...
repo-checkout: false # will auto-checkout the default branch if left on true
output-format: 'text' # other values will always result in successful completion of the action, we need it fail on vulnerabilities
- name: notify slack
# this uses our own 'Github notifications' app in slack
uses: slackapi/[email protected]
if: ${{ failure() }} # only run this steps if one of the previous steps has failed
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL_NUTS_CORE_TEAM }} # webhook is linked to a specific slack channel
webhook-type: incoming-webhook
payload: |
{
"text": "GitHub Action failed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Vulnerabilities detected on a production branch* :rotating_light:\n govulncheck detected vulnerabilities on one of the production branches.\n See workflow for more info."
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": ":github: Failed workflow"
},
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}