Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: devops-maturity/devops-maturity-action@main
- uses: devops-maturity/devops-maturity-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down Expand Up @@ -79,6 +79,7 @@ D202: false # Functional Testing (must have)
| `commit-message` | no | `chore: update devops-maturity badges` | Commit message for the badge update. |
| `pr-title` | no | `chore: update devops-maturity badges` | Title of the pull request. |
| `pr-body` | no | *(auto-generated)* | Body text of the pull request. |
| `cli-version` | no | *(latest)* | Pin a specific CLI version for reproducible results (e.g. `0.1.0`). |

## Outputs

Expand All @@ -95,7 +96,7 @@ D202: false # Functional Testing (must have)

```yaml
- id: maturity
uses: devops-maturity/devops-maturity-action@main
uses: devops-maturity/devops-maturity-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -123,6 +124,17 @@ shields.io badge using a regular expression. If one is found it is replaced
in-place; if none exists the new badge is prepended before the first Markdown
heading (or at the very top of the file).

## Reproducibility

For reproducible CI results, pin both the action and the CLI to specific versions:

```yaml
- uses: devops-maturity/devops-maturity-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
cli-version: '0.1.0' # pin CLI version
```

## License

[Apache 2.0](LICENSE)
42 changes: 29 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ inputs:
[devops-maturity-action](https://github.com/devops-maturity/devops-maturity-action)
based on changes to `devops-maturity.yml`.

cli-version:
description: >
Version of the devops-maturity CLI to install (e.g. '0.1.0').
Defaults to latest. Pinning a specific version ensures reproducible results.
required: false
default: ''

outputs:
score:
description: 'Overall DevOps maturity score as a percentage (e.g. "72.3%").'
Expand Down Expand Up @@ -90,27 +97,36 @@ runs:

- name: Install devops-maturity CLI
shell: bash
run: pip install --quiet devops-maturity
run: |
if [ -n "${{ inputs.cli-version }}" ]; then
pip install --quiet "devops-maturity==${{ inputs.cli-version }}"
else
pip install --quiet devops-maturity
fi

# ── 2. Run the assessment ─────────────────────────────────────────────────
# ── 2. Run the assessment (JSON output, no text parsing) ─────────────────
- name: Run devops-maturity assessment
id: assessment
shell: bash
run: |
OUTPUT=$(dm config --file "${{ inputs.file }}" 2>&1)
echo "$OUTPUT"

SCORE=$(echo "$OUTPUT" | awk '/Your score: / {print $NF}')
LEVEL=$(echo "$OUTPUT" | awk '/Your maturity level: / {print $NF}')
BADGE_URL=$(echo "$OUTPUT" | awk '/Badge URL: / {print $NF}')
# Prefer the CLI-provided Markdown badge; fall back to constructing it
BADGE_MD=$(echo "$OUTPUT" | sed -n 's/^Markdown badge: //p')
if [ -z "$BADGE_MD" ] && [ -n "$BADGE_URL" ]; then
BADGE_MD="[![DevOps Maturity](${BADGE_URL})](https://devops-maturity.github.io/)"
JSON_OUTPUT=$(dm config --file "${{ inputs.file }}" --format json 2>&1)
echo "$JSON_OUTPUT"

# Validate that we got valid JSON
if ! echo "$JSON_OUTPUT" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; then
echo "ERROR: could not parse assessment output as JSON"
echo "Raw output was:"
echo "$JSON_OUTPUT"
exit 1
fi

SCORE=$(echo "$JSON_OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['score'])")
LEVEL=$(echo "$JSON_OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['level'])")
BADGE_URL=$(echo "$JSON_OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['badge_url'])")
BADGE_MD=$(echo "$JSON_OUTPUT" | python3 -c "import sys,json; print(json.load(sys.stdin)['badge_markdown'])")

if [ -z "$LEVEL" ] || [ -z "$BADGE_URL" ]; then
echo "ERROR: could not parse assessment output"
echo "ERROR: missing required fields in JSON output"
exit 1
fi

Expand Down
Loading