1
+ name : Fossa
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+
8
+ defaults :
9
+ run :
10
+ shell : bash
11
+
12
+ env :
13
+ FOSSA_VER : 1.1.0
14
+ FOSSA_URL : https://github.com/fossas/fossa-cli/releases/download
15
+ GOLANG_VERSION : 1.15
16
+
17
+ jobs :
18
+
19
+ scan :
20
+ name : Fossa
21
+ runs-on : ubuntu-18.04
22
+ steps :
23
+ - name : Checkout Repository
24
+ uses : actions/checkout@v2
25
+ - name : Setup Golang Environment
26
+ uses : actions/setup-go@v2
27
+ with :
28
+ go-version : ' ${{ env.GOLANG_VERSION }}'
29
+ - name : Configure Fossa CLI
30
+ run : |
31
+ wget ${{ env.FOSSA_URL }}/v${{ env.FOSSA_VER }}/fossa-cli_${{ env.FOSSA_VER }}_linux_amd64.tar.gz
32
+ tar xzf fossa-cli_${{ env.FOSSA_VER }}_linux_amd64.tar.gz
33
+ ./fossa init
34
+ - name : Run License Scan
35
+ env :
36
+ FOSSA_API_KEY : ${{ secrets.FOSSA_TOKEN }}
37
+ GO111MODULE : on
38
+ GOPATH : /home/runner/go
39
+ run : ./fossa analyze -t ${GITHUB_REPOSITORY#*/} -b ${GITHUB_REF##*/}
40
+
41
+ notify :
42
+ name : Notify
43
+ runs-on : ubuntu-18.04
44
+ needs : scan
45
+ if : always()
46
+ steps :
47
+ - name : Workflow Status
48
+ id : check
49
+ uses : martialonline/workflow-status@v1
50
+ - name : Output Variables
51
+ id : commit
52
+ run : |
53
+ echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
54
+ echo "::set-output name=repo::${GITHUB_REPOSITORY#*/}"
55
+ - name : Send Notification
56
+ uses : 8398a7/action-slack@v3
57
+ if : steps.check.outputs.status == 'failure'
58
+ with :
59
+ status : custom
60
+ custom_payload : |
61
+ {
62
+ username: 'Fossa Scan',
63
+ icon_emoji: ':fossa:',
64
+ mention: 'channel',
65
+ attachments: [{
66
+ title: '[${{ steps.commit.outputs.repo }}] ${{ github.workflow }} license scan has failed',
67
+ color: 'danger',
68
+ fields: [{
69
+ title: 'Commit Hash',
70
+ value: '${{ steps.commit.outputs.sha }}',
71
+ short: true
72
+ },
73
+ {
74
+ title: 'Author',
75
+ value: '${{ github.actor }}',
76
+ short: true
77
+ },
78
+ {
79
+ title: 'Job URL',
80
+ value: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}',
81
+ short: false
82
+ }]
83
+ }]
84
+ }
85
+ env :
86
+ GITHUB_TOKEN : ${{ github.token }}
87
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK }}
0 commit comments