Skip to content

Commit

Permalink
Merge pull request #7 from nikpivkin/outdated-rego-upd
Browse files Browse the repository at this point in the history
chore: restore outdated-api-update workflow
  • Loading branch information
simar7 authored Sep 21, 2023
2 parents fc4059f + a4ccfad commit 8fe591d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/outdated-api-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: update outdated-api policy
on:
workflow_dispatch: {}
schedule:
- cron: "0 0 * * 0" # Sunday midnight
permissions:
contents: write

jobs:
outdated:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.AUTO_COMMIT_TOKEN }}
- name: Fetch outdated API data from trivy-db-data repo
id: outdatedapi
uses: fjogeleit/http-request-action@v1
with:
url: "https://raw.githubusercontent.com/aquasecurity/trivy-db-data/main/k8s/api/k8s-outdated-api.json"
method: "GET"
- name: embed outdatedapi-data with in dynamic rego policy
env:
OUTDATE_API_DATA: ${{ toJson(steps.outdatedapi.outputs.response) }}
run: |
make outdated-api-updated
- name: Setup OPA
uses: ./.github/actions/setup-opa
- name: OPA Format
run: |
opa fmt -w . | grep -v vendor || true
- name: commit and push updated outdated-api policy when changes found
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update outdated-api policy data
push_options: --force
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DYNAMIC_REGO_FOLDER=./rules/kubernetes/policies/dynamic

.PHONY: schema
schema:
go run ./cmd/schema generate
Expand Down Expand Up @@ -32,3 +34,6 @@ docs-test:
.PHONY: id
id:
@go run ./cmd/id

outdated-api-updated:
sed -i.bak "s|recommendedVersions :=.*|recommendedVersions := $(OUTDATE_API_DATA)|" $(DYNAMIC_REGO_FOLDER)/outdated_api.rego && rm $(DYNAMIC_REGO_FOLDER)/outdated_api.rego.bak

0 comments on commit 8fe591d

Please sign in to comment.