Skip to content

Version Comparison

Version Comparison #2

name: Version Comparison
on:
workflow_dispatch:
inputs:
baseRef:
description: 'Base CLI ref (tag/branch/SHA)'
baseRulesRef:
description: 'Base rules ref'
testRef:
description: 'Test CLI ref (tag/branch/SHA)'
testRulesRef:
description: 'Test rules ref'
jobs:
setup:
name: Setup version comparison
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.load_json.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: load_json
run : |
echo "matrix=$(npx --yes json5 ./kpi_scan/kpi_repo_list.json5)" >> $GITHUB_OUTPUT
- name: Checkout base CLI
uses: actions/checkout@v4
with:
repository: bearer/bearer
ref: ${{ inputs.baseRef }}
path: base-cli
- name: Checkout test CLI
uses: actions/checkout@v4
with:
repository: bearer/bearer-rules
ref: ${{ inputs.testRef }}
path: test-cli
- name: Checkout base rules
uses: actions/checkout@v4
with:
repository: bearer/bearer-rules
ref: ${{ inputs.baseRulesRef }}
path: base-rules
- name: Checkout test rules
uses: actions/checkout@v4
with:
repository: bearer/bearer-rules
ref: ${{ inputs.testRulesRef }}
path: test-rules
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Build base CLI
run: |
cd ./base-cli
go build -o ../base-bearer ./cmd/bearer/main.go
- name: Build test CLI
run: |
cd ./test-cli
go build -o ../base-bearer ./cmd/bearer/main.go
test:
needs: [setup]
name: Run version comparison scans for ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Checkout KPI repo
uses: actions/checkout@v4
with:
repository: ${{ matrix.repository_url }}
path: ${{ matrix.name }}
- run: |
./base-bearer scan ${{ matrix.name }} --format json --exit-code 0 | jq > base.json
- run: |
./test-bearer scan ${{ matrix.name }} --format json --exit-code 0 | jq > test.json
- run: |
diff -u base.json test.json