Coder Social home page Coder Social logo

koozz / opa-action Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 35 KB

OPA Pull-Request Assessor; Automatically check your structured configuration data using Open Policy Agent.

License: Apache License 2.0

Dockerfile 13.65% Shell 77.69% Open Policy Agent 8.66%

opa-action's Introduction

OPA-action

I contributed to open-policy-agent/conftest with GitHub flavored output.

Now you can simply use Conftest directly which makes this action obsolete.

---
name: Conftest

on:
  pull_request:
    branches: 
      - main

jobs:
  conftest:
    runs-on: ubuntu-latest
    container: openpolicyagent/conftest:latest
    steps:
      - name: Code checkout
        uses: actions/checkout@v2
      - name: Validate Kubernetes policy
        run: |
          conftest test -o github -p examples/kubernetes/policy examples/kubernetes/deployment.yaml

The -o github will be responsible for annotating the files where policy violations are found.

Archived readme

OPA stands for OPA Pull-Request Assessor and is a GitHub Action that checks files against policies (configured in the same repo). It's using the original OPA (Open Policy Agent) through the use of Conftest.

Usage

Start using this OPA-action in three simple steps:

  1. Create your policies
  2. Create a configuration
  3. Trigger GitHub Action

Create your policies

Create a folder (i.e. policies) with your policy files written in the Rego language. For sample policies, check out the Conftest examples or write your own using Rego, the OPA Policy Language.

Create a configuration

Configure in either .opa-action.yaml or .github/opa-action.yaml where your policy files can be found (path, the folder you created in the step before) followed by pairs of files or filepatterns (sources) and the package/namespace (package) the files should be tested against and optionally if this should not fail the check (no_fail, default or absense means 'false' and will fail the check on errors).

---
path: policy
rego:
  - sources: "Dockerfile"
    package: "docker"
    no_fail: true
  - sources: ".github/workflows/*.yml"
    package: "workflows"

Trigger GitHub Action

Add the GitHub Action to your workflows, either on its own as a separate workflow or add it as an action between the code checkout and the rest of your existing workflow.

---
name: Policy check

on:
  pull_request:
    branches: 
      - main

jobs:
  policy-check:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v2
      - name: OPA Pull-Request Assessor
        uses: koozz/opa-action@latest

If your satisfied, follow best practices and pin the action to a specific version.

License

Apache License, Version 2.0

opa-action's People

Contributors

koozz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

abdelkhalek7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.