-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
168 lines (161 loc) · 5.29 KB
/
action.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
---
name: NSFW Detection Action
author: Yevhen Fabizhevskyi
description: This GitHub Action detects NSFW content in committed files.
branding:
icon: alert-octagon
color: red
inputs:
provider:
description: Provider identifier.
required: true
api-key:
description: API key required for the selected provider.
required: true
threshold:
description: |
The action will fail if the NSFW detection value is greater than or equal
to this parameter.
required: true
extensions:
description: Comma-separated list of file extensions for NSFW detection.
required: false
default: jpeg,jpg,png,gif,webp,tiff,bmp
types:
description: Comma-separated types of changes made during work on the branch.
required: false
default: added,copied,modified,renamed
runs:
using: composite
steps:
- name: Validate inputs
if: env.SCAN_SCA_EXIT_CODE == '0'
id: validate-inputs
env:
INPUT_PROVIDER: "${{ inputs.provider }}"
INPUT_API_KEY: "${{ inputs.api-key }}"
INPUT_THRESHOLD: "${{ inputs.threshold }}"
INPUT_EXTENSIONS: "${{ inputs.extensions }}"
INPUT_TYPES: "${{ inputs.types }}"
run: |
./validate-inputs.sh \
"${INPUT_PROVIDER}" \
"${INPUT_API_KEY}" \
"${INPUT_THRESHOLD}" \
"${INPUT_EXTENSIONS}" \
"${INPUT_TYPES}"
shell: sh
working-directory: ${{ github.action_path }}/src
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: "**.{${{ inputs.extensions }}}"
- name: Setup jq
if: (
(
contains(format(',{0},', inputs.types), ',added,')
&& steps.changed-files.outputs.added_files_count != '0'
)
|| (
contains(format(',{0},', inputs.types), ',copied,')
&& steps.changed-files.outputs.copied_files_count != '0'
)
|| (
contains(format(',{0},', inputs.types), ',modified,')
&& steps.changed-files.outputs.modified_files_count != '0'
)
|| (
contains(format(',{0},', inputs.types), ',renamed,')
&& steps.changed-files.outputs.renamed_files_count != '0'
)
)
uses: dcarbone/install-jq-action@v3
- name: Classify added files
if: (
contains(format(',{0},', inputs.types), ',added,')
&& steps.changed-files.outputs.added_files_count != '0'
)
env:
INPUT_PROVIDER: ${{ inputs.provider }}
INPUT_API_KEY: ${{ inputs.api-key }}
INPUT_THRESHOLD: ${{ inputs.threshold }}
run: |
${GITHUB_ACTION_PATH}/src/providers/${INPUT_PROVIDER}.sh \
"${{ steps.changed-files.outputs.added_files }}" \
"created" \
"${INPUT_API_KEY}" \
"${INPUT_THRESHOLD}"
shell: sh
- name: Classify copied files
if: (
contains(format(',{0},', inputs.types), ',copied,')
&& steps.changed-files.outputs.copied_files_count != '0'
)
env:
INPUT_PROVIDER: ${{ inputs.provider }}
INPUT_API_KEY: ${{ inputs.api-key }}
INPUT_THRESHOLD: ${{ inputs.threshold }}
run: |
${GITHUB_ACTION_PATH}/src/providers/${INPUT_PROVIDER}.sh \
"${{ steps.changed-files.outputs.copied_files }}" \
"copied" \
"${INPUT_API_KEY}" \
"${INPUT_THRESHOLD}"
shell: sh
- name: Classify modified files
if: (
contains(format(',{0},', inputs.types), ',modified,')
&& steps.changed-files.outputs.modified_files_count != '0'
)
env:
INPUT_PROVIDER: ${{ inputs.provider }}
INPUT_API_KEY: ${{ inputs.api-key }}
INPUT_THRESHOLD: ${{ inputs.threshold }}
run: |
${GITHUB_ACTION_PATH}/src/providers/${INPUT_PROVIDER}.sh \
"${{ steps.changed-files.outputs.modified_files }}" \
"modified" \
"${INPUT_API_KEY}" \
"${INPUT_THRESHOLD}"
shell: sh
- name: Classify renamed files
if: (
contains(format(',{0},', inputs.types), ',renamed,')
&& steps.changed-files.outputs.renamed_files_count != '0'
)
env:
INPUT_PROVIDER: ${{ inputs.provider }}
INPUT_API_KEY: ${{ inputs.api-key }}
INPUT_THRESHOLD: ${{ inputs.threshold }}
run: |
${GITHUB_ACTION_PATH}/src/providers/${INPUT_PROVIDER}.sh \
"${{ steps.changed-files.outputs.renamed_files }}" \
"renamed" \
"${INPUT_API_KEY}" \
"${INPUT_THRESHOLD}"
shell: sh
- name: Print message
if: (
(
!contains(format(',{0},', inputs.types), ',added,')
|| steps.changed-files.outputs.added_files_count == '0'
)
&& (
!contains(format(',{0},', inputs.types), ',copied,')
|| steps.changed-files.outputs.copied_files_count == '0'
)
&& (
!contains(format(',{0},', inputs.types), ',modified,')
|| steps.changed-files.outputs.modified_files_count == '0'
)
&& (
!contains(format(',{0},', inputs.types), ',renamed,')
|| steps.changed-files.outputs.renamed_files_count == '0'
)
)
run: |
. ./logging.sh
log_info "No files found for classification"
shell: sh
working-directory: ${{ github.action_path }}/src/lib