Skip to content

Commit d59e707

Browse files
authored
feat: allow version to be specified (#21)
* feat: allow version to be specified * fix: make empty version work * fix: wire up outputs to composite step
1 parent 4c36497 commit d59e707

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ you can see this workflow in action on our [demo repo](https://github.com/Bearer
6161
6262
## Inputs
6363
64+
### `version`
65+
66+
**Optional** Specify the Bearer version to use. This must match a Bearer release name.
67+
6468
### `scanner`
6569

6670
**Optional** Specify the comma-separated scanner to use e.g. `sast,secrets`

action.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ branding:
44
icon: "check-square"
55
color: "purple"
66
inputs:
7+
version:
8+
description: "Specify the Bearer version to use. This must match a Bearer release name."
9+
required: false
10+
default: ""
711
scanner:
812
description: "Specify the comma separated scanners e.g. --scanner secrets,sast"
913
required: false
@@ -31,15 +35,28 @@ inputs:
3135
outputs:
3236
rule_breaches:
3337
description: "Details of any rule breaches that occur"
38+
value: ${{ steps.run.outputs.rule_breaches }}
3439
exit_code:
3540
description: "exit code from binary"
41+
value: ${{ steps.run.outputs.exit_code }}
3642
runs:
37-
using: "docker"
38-
image: "Dockerfile"
39-
args:
40-
- "--scanner=${{ inputs.scanner }}"
41-
- "--config-file=${{ inputs.config-file }}"
42-
- "--only-rule=${{ inputs.only-rule }}"
43-
- "--skip-rule=${{ inputs.skip-rule }}"
44-
- "--skip-path=${{ inputs.skip-path }}"
45-
- "--severity=${{ inputs.severity }}"
43+
using: "composite"
44+
steps:
45+
- shell: bash
46+
run: |
47+
VERSION="${{ inputs.version }}"
48+
if [[ ! -z "$VERSION" ]]; then
49+
VERSION="v${VERSION#v}"
50+
fi
51+
52+
curl -sfL https://raw.githubusercontent.com/Bearer/bearer/main/contrib/install.sh | sh -s -- -b "$RUNNER_TEMP" "$VERSION"
53+
- id: run
54+
shell: bash
55+
run: |
56+
$GITHUB_ACTION_PATH/entrypoint.sh \
57+
"--scanner=${{ inputs.scanner }}" \
58+
"--config-file=${{ inputs.config-file }}" \
59+
"--only-rule=${{ inputs.only-rule }}" \
60+
"--skip-rule=${{ inputs.skip-rule }}" \
61+
"--skip-path=${{ inputs.skip-path }}" \
62+
"--severity=${{ inputs.severity }}"

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Filter out any empty args
44
args=$(for var in "$@"; do echo "$var";done | grep =.)
55

6-
RULE_BREACHES=`bearer scan --quiet ${args//$'\n'/ } .`
6+
RULE_BREACHES=`$RUNNER_TEMP/bearer scan --quiet ${args//$'\n'/ } .`
77
SCAN_EXIT_CODE=$?
88

99
echo "::debug::$RULE_BREACHES"

0 commit comments

Comments
 (0)