Skip to content

Commit

Permalink
Merge pull request #12 from DoodleScheduling/fix-generator
Browse files Browse the repository at this point in the history
fix: generator refactoring
  • Loading branch information
raffis authored Oct 4, 2024
2 parents e2fff38 + 408a2bd commit 28b6eb4
Show file tree
Hide file tree
Showing 16 changed files with 521 additions and 655 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pr-actions

permissions: {}

on:
pull_request:
branches:
- 'master'

jobs:
ensure-sha-pinned:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@0901cf7b71c7ea6261ec69a3dc2bd3f9264f893e # v3.0.12
with:
# slsa-github-generator requires using a semver tag for reusable workflows.
# See: https://github.com/slsa-framework/slsa-github-generator#referencing-slsa-builders-and-generators
allowlist: |
slsa-framework/slsa-github-generator
27 changes: 27 additions & 0 deletions .github/workflows/pr-goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pr-gorelaser

permissions: {}

on:
pull_request:
branches:
- 'master'

jobs:
validate-config:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Validate .goreleaser.yaml
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
version: latest
args: check
env:
RUNNER_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.DOODLE_OSS_BOT}}
12 changes: 10 additions & 2 deletions .github/workflows/pr-label.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ name: pr-label
on:
pull_request:

permissions: {}

jobs:
size-label:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
permissions:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: size-label
uses: "pascalgn/size-label-action@b1f4946f381d38d3b5960f76b514afdfef39b609"
uses: "pascalgn/size-label-action@49850f3557d4b77f0b2e759829defd77ccc07c54"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18 changes: 18 additions & 0 deletions .github/workflows/pr-stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pr-stale
on:
schedule:
- cron: '30 1 * * *'

permissions: {}

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
days-before-close: '120'
stale-pr-label: stale
repo-token: ${{ github.token }}
28 changes: 28 additions & 0 deletions .github/workflows/pr-trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: pr-trivy
on: pull_request

permissions: {}

jobs:
trivy:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Trivy fs scan
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
scan-type: 'fs'
ignore-unfixed: true
scanners: license,vuln,secret
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with:
sarif_file: 'trivy-results.sarif'
79 changes: 79 additions & 0 deletions .github/workflows/report-on-vulnerabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: report-on-vulnerabilities

permissions: {}

on:
workflow_dispatch: {}
schedule:
- cron: '0 6 * * *'

jobs:
scan:
runs-on: ubuntu-latest
outputs:
results: ${{ steps.parse-results.outputs.results }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Scan for vulnerabilities
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
image-ref: ghcr.io/doodlescheduling/flux-build:latest
format: json
scanners: vuln,secret
ignore-unfixed: false
severity: HIGH,CRITICAL
output: scan.json

- name: Parse scan results
id: parse-results
continue-on-error: true
run: |
VULNS=$(cat scan.json | jq '[.Results[].Vulnerabilities | select(. != null) | .[]] | length')
if [[ $VULNS -eq 0 ]]
then
echo "No vulnerabilities found, halting"
echo "results=nothing" >> $GITHUB_OUTPUT
else
echo "Vulnerabilities found, creating issue"
echo "results=found" >> $GITHUB_OUTPUT
fi
- name: Upload vulnerability scan report
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
if: steps.parse-results.outputs.results == 'found'
with:
name: scan.json
path: scan.json
if-no-files-found: error

open-issue:
runs-on: ubuntu-latest
if: needs.scan.outputs.results == 'found'
needs: scan
permissions:
issues: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Download scan
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: scan.json
- name: Set scan output
id: set-scan-output
run: echo "results=$(cat scan.json)" >> $GITHUB_OUTPUT
- uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESULTS: ${{ steps.set-scan-output.outputs.results }}
with:
filename: .github/ISSUE_TEMPLATE/VULN-TEMPLATE.md
33 changes: 13 additions & 20 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,30 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '18 10 * * 3'

permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for codeQL to write security events
permissions: {}

jobs:
fossa:
name: fossa
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Run FOSSA scan and upload build data
uses: fossa-contrib/fossa-action@6728dc6fe9a068c648d080c33829ffbe56565023 #v2.0.0
with:
# FOSSA Push-Only API Token
fossa-api-key: 956b9b92c5b16eeca1467cebe104f2c3
github-token: ${{ github.token }}

codeql:
name: codeql
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for codeQL to write security events
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Initialize CodeQL
uses: github/codeql-action/init@c73d8a69e18598d5de9d6bf5de3a374253cde261 #codeql-bundle-20221020
uses: github/codeql-action/init@f0a12816612c7306b485a22cb164feb43c6df818 # codeql-bundle-20221020
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@c73d8a69e18598d5de9d6bf5de3a374253cde261 #codeql-bundle-20221020
uses: github/codeql-action/autobuild@f0a12816612c7306b485a22cb164feb43c6df818 # codeql-bundle-20221020
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@c73d8a69e18598d5de9d6bf5de3a374253cde261 #codeql-bundle-20221020
uses: github/codeql-action/analyze@f0a12816612c7306b485a22cb164feb43c6df818 # codeql-bundle-20221020
45 changes: 45 additions & 0 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: scorecard
on:
branch_protection_rule:
schedule:
- cron: '18 14 * * 5'
push:
branches: [ "master" ]

permissions: {}

jobs:
scorecard:
runs-on: ubuntu-latest
permissions:
security-events: write
id-token: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: "Checkout code"
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
publish_results: true

- name: "Upload artifact"
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with:
sarif_file: results.sarif
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
./tfxunpack
bin
coverage.out
dist
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
project_name: tfxunpack

builds:
Expand Down Expand Up @@ -84,21 +85,20 @@ docker_manifests:
brews:
- ids:
- tfxunpack
tap:
repository:
owner: doodlescheduling
name: tfxunpack
token: "{{ .Env.GITHUB_TOKEN }}"
description: Extract crossplane resources
description: Build kustomize overlays with flux2 HelmRelease support
homepage: https://github.com/DoodleScheduling/tfxunpack
folder: Formula
directory: Formula
test: |
system "#{bin}/tfxunpack -h"
signs:
- cmd: cosign
certificate: "${artifact}.pem"
env:
- GITHUB_TEOKN=$RUNNER_TOKEN
- COSIGN_EXPERIMENTAL=1
args:
- sign-blob
Expand Down
Loading

0 comments on commit 28b6eb4

Please sign in to comment.