Reusable Workflows

This directory contains reusable GitHub Actions workflows shared across Apache Commons projects. They provide a consistent and secure CI setup without duplicating configuration in each repository.

CodeQL (codeql-analysis-reusable.yml)

Runs a CodeQL security analysis and uploads the results to GitHub's code-scanning dashboard. A separate job is created for each analyzed language.

To speed up the Java autobuild step, the workflow tries to restore a Maven dependency cache saved by a prior build job. For the cache to be found, the build workflow must store it under the key:

${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

Inputs

InputTypeDefaultDescription
languagesstring"["actions", "java"]"JSON array of CodeQL language identifiers to analyze.

Required permissions

The caller job must grant:

permissions:
  actions: read
  contents: read
  security-events: write

Usage example

name: CodeQL

on:
  push:
    branches: [ "master" ]
  pull_request: { }
  schedule:
    - cron: '33 9 * * 4'   # Randomize this expression

# Explicitly drop all permissions for security.
permissions: { }

jobs:
  codeql:
    # Intentionally not pinned: maintained by the same PMC.
    uses: apache/commons-parent/.github/workflows/codeql-analysis-reusable.yml@master
    permissions:
      actions: read
      contents: read
      security-events: write

Scorecards (scorecards-analysis-reusable.yml)

Runs an OpenSSF Scorecard analysis and uploads the results to GitHub's code-scanning dashboard. For public repositories, the results are also published to the Scorecard API, enabling the Scorecard badge.

This workflow has no inputs.

Required permissions

In addition to uploading results to the code-scanning dashboard (security-events: write), the workflow authenticates with securityscorecards.dev using an OIDC token (id-token: write). The caller job must grant:

permissions:
  actions: read
  contents: read
  security-events: write
  id-token: write

Usage example

name: Scorecards

on:
  branch_protection_rule:
  schedule:
    - cron: '30 1 * * 6'   # Randomize this expression
  push:
    branches: [ "master" ]

# Explicitly drop all permissions for security.
permissions: { }

jobs:
  scorecards:
    # Intentionally not pinned: maintained by the same PMC.
    uses: apache/commons-parent/.github/workflows/scorecards-analysis-reusable.yml@master
    permissions:
      actions: read
      contents: read
      security-events: write
      id-token: write