Skip to content

Commit

Permalink
Add github action for validating proper oscal assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
rahearn committed Oct 3, 2024
1 parent 8ed91fd commit b063d52
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/actions/trestle-cmd/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Run a docker-trestle command"
description: "Sets up workspace for running a single command in docker-trestle"
inputs:
tag:
description: docker-trestle tag to use.
required: false
default: 20240930
cmd:
description: Command to run within docker-trestle
required: true
runs:
using: "composite"
steps:
- name: Run cmd
shell: bash
run: docker run -u "$(id -u):$(id -g)" -v $GITHUB_WORKSPACE:/app/docs:rw ghcr.io/gsa-tts/trestle:${{ inputs.tag }} ${{ inputs.cmd }}
49 changes: 49 additions & 0 deletions .github/workflows/validate-oscal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Validate OSCAL Assembly

on: [pull_request]

permissions:
contents: read
pull-requests: write

jobs:
validate_cd:
name: Validate component definition format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Validate Component
uses: ./.github/actions/trestle-cmd
with:
cmd: trestle validate -f component-definitions/cg-egress-proxy/component-definition.json

check_cd:
name: Check assembly is current
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check assembly
uses: ./.github/actions/trestle-cmd
with:
cmd: bin/assemble-cgep-json

- name: Check no changes exist
run: git diff --quiet

- name: Comment on pull request
if: failure()
uses: actions/github-script@v4
with:
script: |
const output = `OSCAL assembly detected changes that aren't checked in.
Run \`bin/assemble-cgep-json\` within trestle to ensure markdown changes are reflected in the CD`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
});

0 comments on commit b063d52

Please sign in to comment.