Reusable GitHub Actions workflows and composite actions shared by the Litote repositories.
| Workflow | Purpose | Required permissions |
|---|---|---|
zizmor.yml |
Audits the GitHub workflows of the caller with zizmor | contents: read |
pr-title.yml |
Checks that the pull request title follows Conventional Commits | pull-requests: read |
gradle-check.yml |
Builds and tests a Gradle project, runs SonarCloud, and optionally runs a macOS job | contents: read |
gradle-verification.yml |
Regenerates the Gradle verification metadata of a Dependabot pull request | contents: read |
flutter-update-goldens.yml |
Regenerates the Flutter golden files on macOS in a job without write access, then commits them from another job, opens a pull request and runs the CI on it | actions: write, contents: write, pull-requests: write |
dependabot-commit-guard.yml |
Fails when a commit of a Dependabot pull request is not signed by GitHub, or when a commit added to it does not come from the bot, or changes other paths than the given ones | contents: read, pull-requests: read |
dependabot-auto-merge.yml |
Approves and merges the minor and patch updates of the given Dependabot ecosystems, and the Docker digest bumps of the same tag, once the required checks pass | contents: read, pull-requests: read |
| Action | Purpose |
|---|---|
setup-gradle |
Sets up the JDK and Gradle with the shared cache settings. With cache-encryption-key, keeps the configuration cache between the runs of a job, so that a new commit reuses it when its build configuration is unchanged |
detect-changes |
Tells whether the pull request or the pushed commits change code: by default the files of a Gradle build, including its wrapper, properties and resources. Needs a checkout with fetch-depth: 0 |
sonar-gradle |
Runs the aggregated JaCoCo report and the SonarCloud analysis. Does nothing without a token |
app-token |
Creates a GitHub App token for the current repository only, contents: write by default. Takes the App ID or the client ID, and refuses an empty set of permissions, which would grant every permission of the App |
commit-via-api |
Commits local changes through the GitHub API, so that GitHub signs the commit. Keeps the executable bit and the symbolic links. Does nothing when the branch already has this content, or when it no longer matches expected-head. Its sha output is the commit created, empty when nothing was committed |
upload-regenerated-files |
Hands regenerated files over to another job, so that the job that runs the build needs no secret. Leaves out the files that git ignores. Runs on Linux and macOS |
apply-regenerated-files |
Copies the given paths of upload-regenerated-files to the working directory, in the job that commits them |
check-abi-additions |
Keeps the regenerated ABI dumps whose changes only add non abstract members, and restores the others from the index, in the job that commits them |
check-bot-commits |
Checks the commits of a Dependabot pull request. Does nothing on another pull request |
check-excluded-dependencies |
Tells whether a dependency of a Dependabot pull request matches one of the given glob patterns |
check-docker-digest |
Tells whether a pull request only changes the digests of the same Docker tags |
setup-flutter |
Sets up Flutter, pinned to the exact version of .flutter-version |
setup-terraform |
Sets up Terraform, pinned to an exact version, and runs terraform init with the committed lock file only |
release-please |
Runs release-please with a GitHub App token, and exposes release_created and tag_name |
set-release-version |
Writes the version of a release tag to VERSION_NAME in gradle.properties, on Linux and macOS |
set-gradle-jvm-args |
Writes org.gradle.jvmargs to gradle.properties, and adds the line when it is missing, on Linux and macOS |
maven-central-publish |
Runs Gradle with the Maven Central credentials and the signing key |
publish-draft-release |
Publishes a draft GitHub release as the latest one |
docker-publish |
Builds a multi-platform Docker image with its provenance and SBOM, and pushes it to GitHub Container Registry |
setup-mkdocs |
Sets up Python and installs MkDocs Material, pinned with hashes in the action, and hides its MkDocs 2 notice |
setup-graalvm |
Sets up GraalVM with native-image, and Gradle with the cache settings of setup-gradle |
gradle-configuration-cache |
Keeps the configuration cache of the build between the runs of a job. Used by setup-gradle and setup-graalvm |
check-native-arch |
Fails when a native Linux (ELF) binary is not built for the expected architecture (arm64 by default) |
A project that needs services or steps between the build and the analysis uses the composite actions in its own job,
instead of gradle-check.yml.
Release workflows stay in each repository, because their jobs differ: Apple targets, the Gradle Plugin Portal, binaries and documentation come between the shared steps. They are built from these composite actions.
Releases are created by release-please from Conventional Commits. Only feat and fix commits trigger a release.
Pin the workflows by SHA, with the tag in a comment, so that Dependabot can update them:
jobs:
zizmor:
permissions:
contents: read
uses: Litote/ci/.github/workflows/zizmor.yml@<sha> # vX.Y.Z
pr-title:
if: github.event_name == 'pull_request'
permissions:
pull-requests: read
uses: Litote/ci/.github/workflows/pr-title.yml@<sha> # vX.Y.ZGroup the updates of these workflows and actions in .github/dependabot.yml, so that a release opens a single pull
request instead of one per workflow or action. Dependabot names each of them by its full path, such as
Litote/ci/.github/actions/setup-gradle, so one pattern matches them all. The group applies within one updates
entry only: list all the directories in its directories rather than in separate entries.
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
exclude:
- "Litote/*"
groups:
litote-ci:
patterns:
- "Litote/ci/*"gradle-check.yml takes its secrets explicitly:
jobs:
check:
permissions:
contents: read
uses: Litote/ci/.github/workflows/gradle-check.yml@<sha> # vX.Y.Z
with:
check-name: Check (JVM / JS / Linux)
jvm-args: -Xmx3g -Dfile.encoding=UTF-8
gradle-args: --max-workers=2
macos-tasks: macosArm64Test iosSimulatorArm64Test compileKotlinIosArm64
secrets:
GRADLE_ENCRYPTION_KEY: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}Its jobs stop after 60 minutes: timeout-minutes and macos-timeout-minutes change it, for the Linux and the macOS job.
gradle-verification.yml is called from a pull_request_target workflow, which keeps the filter on Dependabot:
on:
pull_request_target:
branches: [main]
paths:
- 'gradle/libs.versions.toml'
- 'gradle/wrapper/gradle-wrapper.properties'
jobs:
update-verification-metadata:
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
uses: Litote/ci/.github/workflows/gradle-verification.yml@<sha> # vX.Y.Z
secrets:
RELEASE_PLEASE_APP_ID: ${{ secrets.RELEASE_PLEASE_APP_ID }}
RELEASE_PLEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}A library that checks its ABI (Kotlin abiValidation) can let the bumps that only add to it go through: a new version
of a dependency can add a default method to an interface the library implements. abi-tasks: updateKotlinAbi updates the
dumps in the regeneration build, which then leaves out abi-check-tasks (checkKotlinAbi by default: it would run before
the update). A dump of abi-dumps (**/api/**/*.api by default) is committed with the verification metadata when its
diff only adds lines, and none of them declares an abstract member: such a member breaks the code that implements the
type. A removed, modified or moved line, or an abstract member, leaves the dump as it is: the ABI check of the CI fails,
and the bump needs a pull request with a review. An added enum entry or sealed subclass goes through, though it can
break an exhaustive when of the callers, and so does a member added to an open class, though it can clash with a
member of the same name in a subclass of the callers. abi-check-tasks goes with abi-tasks when these do not come
from the Kotlin Gradle plugin. The guard of the caller must allow the dumps:
allowed-paths: ^(gradle/verification-metadata\.xml|([^/]+/)*api/([^/]+/)*[^/]+\.api)$.
A version bump is a code change: a pull_request_target job that runs a build with the versions of a pull request runs their code, before any review. Such a job must have no secret and no write access, and must not write the Gradle cache (cache-read-only: 'true' on setup-gradle). It hands its result over with upload-regenerated-files, and a second job, which runs no build, commits it with apply-regenerated-files and commit-via-api. Secrets go to that second job only. That job checks out the base branch and only moves the index to the pull request head (git fetch --depth 1 origin <head sha>, then git reset FETCH_HEAD), so that the files of the pull request stay off its disk.
dependabot-commit-guard.yml closes a gap of the auto-merge: the approval of a Dependabot pull request survives its next commits. Make its check required, and call it on every pull request: a required check of a job skipped by the caller stays pending.
commit-guard:
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: read
uses: Litote/ci/.github/workflows/dependabot-commit-guard.yml@<sha> # vX.Y.Z
with:
allowed-paths: ^gradle/verification-metadata\.xml$dependabot-auto-merge.yml relies on the required checks of the ruleset: without them, a pull request is merged without waiting for the CI. It needs allow_auto_merge on the repository:
on:
pull_request_target:
branches: [main]
types: [opened, reopened]
jobs:
auto-merge:
if: github.event.pull_request.user.login == 'dependabot[bot]'
permissions:
contents: read
pull-requests: read
uses: Litote/ci/.github/workflows/dependabot-auto-merge.yml@<sha> # vX.Y.Z
with:
ecosystems: gradle,pub
# optional: these dependencies stay manual
exclude-dependencies: org.mongodb:*
secrets:
RELEASE_PLEASE_APP_ID: ${{ secrets.RELEASE_PLEASE_APP_ID }}
RELEASE_PLEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}The build must set sonar.qualitygate.wait, so that the analysis fails when the quality gate does.
app-token gives a token whose pushes, pull requests and merges trigger the workflows, unlike GITHUB_TOKEN. It is
limited to the current repository, with contents: write unless set otherwise:
- uses: Litote/ci/.github/actions/app-token@<sha> # vX.Y.Z
id: app-token
with:
app-id: ${{ secrets.RELEASE_PLEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}
# optional: permission-contents (default write), permission-pull-requests (default none)
permission-pull-requests: write
- uses: Litote/ci/.github/actions/commit-via-api@<sha> # vX.Y.Z
with:
token: ${{ steps.app-token.outputs.token }}setup-terraform runs terraform init -lockfile=readonly: commit .terraform.lock.hcl, with the hashes of every
platform that runs Terraform (terraform providers lock -platform=linux_amd64 -platform=darwin_arm64). The credentials of
the backend and of the providers are set up before it, as they differ between jobs:
- uses: aws-actions/configure-aws-credentials@<sha> # vX.Y.Z
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- uses: Litote/ci/.github/actions/setup-terraform@<sha> # vX.Y.Z
with:
state-bucket: ${{ vars.TF_STATE_BUCKET }}The Terraform version is bumped here, in the terraform-version default: Dependabot does not update it.
docker-publish builds for linux/amd64 and linux/arm64 by default. The tags are rules of
docker/metadata-action, which also sets the OCI labels; latest
is only added by a rule. A job that pushes needs packages: write:
- uses: Litote/ci/.github/actions/docker-publish@<sha> # vX.Y.Z
with:
image: ghcr.io/litote/my-app
password: ${{ secrets.GITHUB_TOKEN }}
build-args: VERSION_NAME=${{ steps.version.outputs.version }}
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }}
type=raw,value=latestWithout emulation, the target stages of the Dockerfile can only copy files: build them in stages that run on
$BUILDPLATFORM. A Dockerfile that runs commands in the target platforms needs emulate: 'true', which sets up QEMU.
Its version output, to run the pushed image afterwards, is the tag of the rule with the highest
priority, not the first rule: semver rules come
before raw ones by default. Set priority=<n> on the rule of the tag to run.
setup-mkdocs installs the versions of its own requirements.txt, hashed and generated from requirements.in
(uv pip compile requirements.in --universal --generate-hashes -o requirements.txt), so that a project keeps no
requirements file for its documentation site. Dependabot updates them here: a project gets them with the next release
of this repository. Each project keeps its build and its deployment:
- uses: Litote/ci/.github/actions/setup-mkdocs@<sha> # vX.Y.Z
- name: Build the site
run: mkdocs build --strictTo build a site locally with the same versions and hashes as the CI, a project installs the requirements.txt of the
action at the SHA its workflow pins, rather than keeping a copy, for instance in a tools/install-docs.sh script. It
follows the Dependabot updates of this repository with nothing to maintain (the sed expression works with GNU and BSD
sed):
sha=$(sed -n 's#.*Litote/ci/\.github/actions/setup-mkdocs@\([0-9a-f]\{40\}\).*#\1#p' .github/workflows/docs.yml | head -n 1)
python3 -m pip install --only-binary ':all:' --require-hashes \
-r "https://raw.githubusercontent.com/Litote/ci/${sha}/.github/actions/setup-mkdocs/requirements.txt"setup-graalvm replaces setup-gradle in a job that compiles a native image: GraalVM CE 25 by default, and the
same Gradle cache settings. native-image compiles for the platform of the runner, so the job runs on the architecture
of the target, such as ubuntu-24.04-arm for an arm64 Lambda function. check-native-arch then makes the job fail
rather than deploy binaries that cannot start. Dependabot updates the GraalVM setup action here, once for every project:
build-native:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@<sha> # vX.Y.Z
with:
persist-credentials: false
- uses: Litote/ci/.github/actions/setup-graalvm@<sha> # vX.Y.Z
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Compile native image
run: ./gradlew :lambda:packageNative
- uses: Litote/ci/.github/actions/check-native-arch@<sha> # vX.Y.Z
with:
working-directory: lambda/build/native/nativeCompile
binaries: bootstrap libaws-crt-jni.sozizmor.yml takes an optional config input, the path of a zizmor configuration file.
A check of a reusable workflow is named <caller job> / <called job>, for example zizmor / zizmor.
Required status checks must use that name.