fix(ci): use self-hosted runner for unit tests (private repo) #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Security | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| schedule: | |
| - cron: "0 6 * * 1" # Monday 6am UTC | |
| workflow_dispatch: | |
| concurrency: | |
| group: security-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| trivy: | |
| name: Trivy | |
| runs-on: | |
| - self-hosted | |
| - macOS | |
| - ARM64 | |
| - patchloom-vscode | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@v2 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@v6 | |
| - name: Install Trivy | |
| run: | | |
| if ! command -v trivy &>/dev/null; then | |
| brew install trivy | |
| fi | |
| - name: Trivy filesystem scan | |
| run: trivy fs --scanners vuln --severity HIGH,CRITICAL --exit-code 1 --ignore-unfixed . | |
| gitleaks: | |
| name: Gitleaks | |
| runs-on: | |
| - self-hosted | |
| - macOS | |
| - ARM64 | |
| - patchloom-vscode | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@v2 | |
| with: | |
| egress-policy: audit | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install gitleaks | |
| env: | |
| GITLEAKS_VERSION: "8.30.1" | |
| run: | | |
| if command -v gitleaks &>/dev/null; then | |
| echo "gitleaks already installed" | |
| exit 0 | |
| fi | |
| archive="${RUNNER_TEMP}/gitleaks.tar.gz" | |
| bindir="${RUNNER_TEMP}/gitleaks-bin" | |
| mkdir -p "$bindir" | |
| case "$(uname -s)-$(uname -m)" in | |
| Linux-x86_64) platform="linux_x64" ;; | |
| Linux-aarch64) platform="linux_arm64" ;; | |
| Darwin-x86_64) platform="darwin_x64" ;; | |
| Darwin-arm64) platform="darwin_arm64" ;; | |
| *) echo "Unsupported platform: $(uname -s)-$(uname -m)" >&2; exit 1 ;; | |
| esac | |
| curl --retry 5 --retry-all-errors --retry-delay 2 -sSfL \ | |
| -o "$archive" \ | |
| "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_${platform}.tar.gz" | |
| tar -xzf "$archive" -C "$bindir" gitleaks | |
| printf '%s\n' "$bindir" >> "$GITHUB_PATH" | |
| - run: gitleaks detect --source . --exit-code 1 |