Skip to content

Commit

Permalink
Add "upload-only" option
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioheleno committed Jul 31, 2023
1 parent 7614571 commit e0b160f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,31 @@ Authenticated checks have access to additional analysis data. Tokens can be crea
kahu_token: ${{ secrets.KAHU_TOKEN }}
```

### Wait timeout (optional)
### Debug (optional)

The rules can only be executed once the analysis is completed, to avoid an infinite wait, the action waits for `300` seconds (5 minutes) by default. This interval can be customized by using the `wait_timeout` input. It accepts a `positive-integer`.
If the check does not work as expected, it is possible to enable the _debug mode_, using the `debug` input. It accepts `0` (debug mode off) or `1` (debug mode on).

```yaml
- name: Check dependencies
uses: kahu-app/github-action@v1
with:
wait_timeout: 60
debug: 1
```

### Lock file (optional)

The command-line will upload the lock file from `./composer.lock` by default, but it can be customized by using the `lock_file` input. It accepts a `non-empty-string` (path to lockfile).

```yaml
- name: Check dependencies
uses: kahu-app/github-action@v1
with:
lock_file: './my-app/composer.lock'
```

### Rules file (optional)

The command-line will load rules from `./rules.json` by default, but both the path and the file name can be customized by using the `rule_file` input. It accepts a `non-empty-string`.
The command-line will load rules from `./rules.json` by default, but both the path and the file name can be customized by using the `rule_file` input. It accepts a `non-empty-string` (path to rules file).

```yaml
- name: Check dependencies
Expand All @@ -46,26 +57,26 @@ The command-line will load rules from `./rules.json` by default, but both the pa
rule_file: './github/kahu-rules.json'
```

### Lock file (optional)
### Upload only (optional)

The command-line will upload the lock file from `./composer.lock` by default, but it can be customized by using the `lock_file` input. It accepts a `non-empty-string`.
It is possible to skip report validation, ie. only upload the manifest file, by changing the `upload_only` input. It accepts `0` (upload & validate) or `1` (upload only).

```yaml
- name: Check dependencies
uses: kahu-app/github-action@v1
with:
lock_file: './my-app/composer.lock'
upload_only: 1
```

### Debug (optional)
### Wait timeout (optional)

If the check does not work as expected, it is possible to enable the _debug mode_, using the `debug` input. It accepts `0` or `1`.
The rules can only be executed once the analysis is completed, to avoid an infinite wait, the action waits for `300` seconds (5 minutes) by default. This interval can be customized by using the `wait_timeout` input. It accepts a `positive-integer` (number of seconds).

```yaml
- name: Check dependencies
uses: kahu-app/github-action@v1
with:
debug: 1
wait_timeout: 60
```

## License
Expand Down
22 changes: 13 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ branding:
color: 'gray-dark'

inputs:
debug:
description: 'Enable debug mode (high verbosity level)'
required: false
default: 0
kahu_token:
description: 'An access token that you can use to authenticate on Kahu.app'
required: false
default: 'github-action'
wait_timeout:
description: 'Interval in seconds to wait for the analysis to be completed before giving up'
lock_file:
description: 'Custom path to lockfile'
required: false
default: 300
default: './composer.lock'
rule_file:
description: 'Custom path to rules file'
required: false
default: './rules.json'
lock_file:
description: 'Custom path to lockfile'
required: false
default: './composer.lock'
debug:
description: 'Enable debug mode (high verbosity level)'
upload_only:
description: 'Skip validation step'
required: false
default: 0
wait_timeout:
description: 'Interval in seconds to wait for the analysis to be completed before giving up'
required: false
default: 300

runs:
using: 'docker'
Expand Down
13 changes: 12 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ set -o errexit
set -o noglob
set -o nounset

echo "### Manifest Upload" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if test "${INPUT_DEBUG-0}" == "1"; then
echo "[!] DEBUG MODE ACTIVE [!]"
echo "Debug mode active!" >>> $GITHUB_STEP_SUMMARY

set -o xtrace
fi

Expand All @@ -18,11 +23,17 @@ LOCK_FILE="${INPUT_LOCK_FILE:-.\/composer.lock}"
REPORT_ID=$(/usr/bin/kahu-cli manifest:upload --id-only "${LOCK_FILE}")

if ! test $? -eq 0; then
echo "Manifest upload failed"
echo "Manifest upload failed" >> $GITHUB_STEP_SUMMARY

exit 1;
fi

echo "Manifest uploaded successfully ([ID: ${REPORT_ID}](https://kahu.app/reports/${REPORT_ID}))" >> $GITHUB_STEP_SUMMARY

if test "${UPLOAD_ONLY-0}" == "1"; then
exit 0
fi

WAIT_TIMEOUT="${INPUT_WAIT_TIMEOUT:-300}"
RULE_FILE="${INPUT_RULE_FILE:-.\/rules.json}"

Expand Down

0 comments on commit e0b160f

Please sign in to comment.