Skip to content

Github workflows 🤖

This repository serves as a centralized location for reusable GitHub workflows. By defining shared workflows here, we streamline the process of maintaining consistency and quality across all repositories.

This repository contains reusable GitHub workflows intended to be referenced from other repositories via the uses: owner/repo/.github/workflows/<file>@<ref> mechanism.

How to reference these workflows

In your repository, use a uses: reference under jobs to call a reusable workflow.

Example:

yaml
jobs:
  example:
    uses: this-is-tobi/github-workflows/.github/workflows/scan-sonarqube.yml@main
    with:
      SONAR_URL: ${{ vars.SONAR_URL }}
    secrets:
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}

Using Reusable Workflows from Private Repositories

You can use reusable workflows from a private repository, but there are important requirements and limitations:

  • Repository Access: Both the caller and the reusable workflow repository must be private, or both must be internal to the same organization.
  • Authentication: The workflow caller must use a GITHUB_TOKEN or a personal access token (PAT) with actions:read permission to access the private reusable workflow repository.
  • Reference Format: Always reference the reusable workflow using the full path: owner/repo/.github/workflows/workflow.yml@ref.
  • User Permissions: The user or GitHub App triggering the workflow must have access to both repositories.
  • Organization Scope: For cross-repository usage, both repositories should belong to the same organization for seamless access.
  • Token Permissions: The token used must have at least actions:read permission on the reusable workflow repository.

Example:

yaml
jobs:
  example:
    uses: org/private-workflows/.github/workflows/build.yml@main
    secrets:
      GH_TOKEN: ${{ secrets.GH_TOKEN }}

For more details, see: GitHub Docs – Reusing workflows

Available workflows

clean-cache.yml

Delete GitHub Actions caches related to a PR/branch and optionally delete images from GHCR.

Inputs

InputTypeDescriptionRequiredDefault
PR_NUMBERnumberID number of the pull request associated with cacheNo-
BRANCH_NAMEstringBranch name associated with the cacheNo-
COMMIT_SHAstringCommit SHA associated with the cacheNo-
CLEAN_IMAGESbooleanDelete images from ghcr.ioNofalse

Permissions

ScopeAccessDescription
packageswriteManage GHCR packages (used when deleting images with CLEAN_IMAGES)
contentsreadRead repository contents
actionswriteManage Actions caches via gh-actions-cache extension

Notes

  • This workflow is now reusable via workflow_call.
  • The cleanup-cache job deletes GitHub Actions caches for a branch or PR.
  • The infos job generates a build matrix from ./ci/matrix/docker.json.
  • The cleanup-image job deletes images from GHCR using a script, only if CLEAN_IMAGES is true.
  • Requires GITHUB_TOKEN for cache/image deletion.
  • The image cleanup job only runs when the repository variable CLEAN_IMAGES is set to true.

Example

yaml
jobs:
  cleanup:
    uses: this-is-tobi/github-workflows/.github/workflows/clean-cache.yml@main
    with:
      BRANCH_NAME: 'refs/heads/feature/xyz'
      CLEAN_IMAGES: true

docker-build.yml

Build and push container images using Docker Buildx with optional multi-arch support.

Inputs

InputTypeDescriptionRequiredDefault
IMAGE_NAMEstringName of the image to buildYes-
IMAGE_TAGstringTag used to build imageYes-
LATEST_TAGbooleanWhether to tag the image with 'latest'Nofalse
IMAGE_DOCKERFILEstringPath of the DockerfileYes-
IMAGE_CONTEXTstringPath of the build contextYes-
BUILD_AMD64booleanBuild for amd64Notrue
BUILD_ARM64booleanBuild for arm64Notrue
USE_QEMUbooleanUse QEMU emulator for arm64Nofalse
REGISTRY_USERNAMEstringUsername used to login into registryNo-
REGISTRY_PASSWORDstringPassword used to login into registryNo-

Permissions

ScopeAccessDescription
packageswritePush images to GHCR when applicable

Notes

  • Supports Ubuntu 24.04 and ARM runners for matrix builds.
  • LATEST_TAG input allows tagging images as latest.
  • Registry login logic: uses GitHub token for ghcr.io, otherwise uses provided credentials.
  • Digest artifacts are uploaded and merged for multi-arch images.
  • Manifest list is created and pushed after build.

Example

yaml
jobs:
  build:
    uses: this-is-tobi/github-workflows/.github/workflows/docker-build.yml@main
    with:
      IMAGE_NAME: ghcr.io/my-org/my-image
      IMAGE_TAG: 1.2.3
      BUILD_AMD64: true
      BUILD_ARM64: false
      USE_QEMU: false
      REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
      REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}

label-pr.yml

Add or sync labels on pull requests using a configuration file.

Inputs

InputTypeDescriptionRequiredDefault
CONF_PATHstringPath to the labeler configuration fileYes-

Permissions

ScopeAccessDescription
pull-requestswriteRequired to add PR labels

Example

yaml
jobs:
  label:
    uses: this-is-tobi/github-workflows/.github/workflows/label-pr.yml@main
    with:
      CONF_PATH: .github/labeler.yml

preview-app.yml

Comment on PRs with preview URLs and optionally trigger an ArgoCD redeploy for preview environments.

Inputs

InputTypeDescriptionRequiredDefault
APP_URL_TEMPLATEstringTemplate that can include <pr_number>Yes-
PR_NUMBERnumberPull request numberYes-
ARGOCD_APP_NAME_TEMPLATEstringArgoCD app name template (may include <pr_number>)Yes-
ARGOCD_SYNC_PAYLOAD_TEMPLATEstringArgoCD sync payload templateYes-
ARGOCD_URLstringURL of the Argo-CD serverYes-

Secrets

SecretDescriptionRequiredDefault
ARGOCD_TOKENToken used to redeploy the ArgoCD appYes-

Permissions

ScopeAccessDescription
pull-requestswriteRequired to post PR comments

Notes

  • The redeploy step runs only when the PR has the preview label and PR_NUMBER is provided. ARGOCD_TOKEN must be set to authenticate redeploy requests. Template inputs accept the <pr_number> placeholder.

Example

yaml
jobs:
  preview:
    uses: this-is-tobi/github-workflows/.github/workflows/preview-app.yml@main
    with:
      APP_URL_TEMPLATE: 'https://preview.example.com/pr-<pr_number>'
      PR_NUMBER: 123
      ARGOCD_APP_NAME_TEMPLATE: 'preview-app-<pr_number>'
      ARGOCD_SYNC_PAYLOAD_TEMPLATE: '{"force":true}'
    secrets:
      ARGOCD_TOKEN: ${{ secrets.ARGOCD_TOKEN }}

release.yml

Create releases using release-please, optionally tag major/minor versions, and support automerge of generated PRs.

Inputs

InputTypeDescriptionRequiredDefault
TAG_MAJOR_AND_MINORbooleanTag major and minor versionsNofalse
AUTOMERGE_PRERELEASEbooleanAutomatically merge the prerelease PRNofalse
AUTOMERGE_RELEASEbooleanAutomatically merge the release PRNofalse
PRERELEASE_BRANCHstringBranch to create the prerelease onNodevelop
RELEASE_BRANCHstringBranch to create the release onNomain
REBASE_PRERELEASE_BRANCHbooleanRebase prerelease branch on release after releaseNofalse

Secrets

SecretDescriptionRequiredDefault
GH_PATGitHub Personal Access Token (for automerge)No-

Outputs

OutputDescription
release-createdWhether a release was created in this run
major-tagMajor version tag (e.g., 1)
minor-tagMinor version tag (e.g., 2)
patch-tagPatch version tag (e.g., 3)

Permissions

ScopeAccessDescription
contentswriteCreate tags/commits and update manifest files
issueswriteCreate or update issues opened by release tooling
pull-requestswriteCreate, update, and optionally merge release PRs

Notes

  • Reusable via workflow_call; reference with uses: from other repositories.
  • On RELEASE_BRANCH (default main), uses release-please-config.json and .release-please-manifest.json. On PRERELEASE_BRANCH (default develop), uses release-please-config-rc.json and .release-please-manifest-rc.json.
  • If TAG_MAJOR_AND_MINOR: true, tags v<major> and v<major>.<minor> after a release is created.
  • If AUTOMERGE_* is enabled and a PAT is provided, attempts to automerge the release PR.
  • Optionally rebases PRERELEASE_BRANCH onto RELEASE_BRANCH after a release when REBASE_PRERELEASE_BRANCH: true.

Example

yaml
jobs:
  release:
    uses: this-is-tobi/github-workflows/.github/workflows/release.yml@main
    with:
      TAG_MAJOR_AND_MINOR: true

scan-sonarqube.yml

Run SonarQube static analysis and check the quality gate. The workflow optionally downloads a coverage artifact and passes it to SonarQube.

Inputs

InputTypeDescriptionRequiredDefault
COV_IMPORTbooleanWhether to download a coverage artifactNofalse
COV_ARTIFACT_NAMEstringName of the coverage artifactNounit-tests-coverage
COV_ARTIFACT_PATHstringPath where to download the coverage artifactNo./coverage
SONAR_EXTRA_ARGSstringAdditional SonarQube scanner argumentsNo-
SONAR_URLstringURL of the SonarQube serverYes-

Secrets

SecretDescriptionRequiredDefault
SONAR_TOKENSonarQube tokenYes-
SONAR_PROJECT_KEYSonarQube project identifier keyYes-

Example

yaml
jobs:
  scan-sonarqube:
    uses: this-is-tobi/github-workflows/.github/workflows/scan-sonarqube.yml@main
    with:
      SONAR_URL: ${{ vars.SONAR_URL }}
      COV_IMPORT: true
      COV_ARTIFACT_NAME: unit-tests-coverage
      COV_ARTIFACT_PATH: ./coverage
    secrets:
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}

Notes

  • When COV_IMPORT is true the workflow downloads the artifact using COV_ARTIFACT_NAME into COV_ARTIFACT_PATH before running the SonarQube scan; when COV_IMPORT is false no download is attempted. For pull requests, it passes PR decoration args; otherwise it analyzes the current branch. Default sources are apps,packages; override or extend via SONAR_EXTRA_ARGS (e.g., -Dsonar.sources=.).

scan-trivy.yml

Run Trivy vulnerability scans on container images and/or configuration files and upload SARIF reports to GitHub Security.

Inputs

InputTypeDescriptionRequiredDefault
IMAGEstringImage used to perform scan (eg. docker.io/debian:latest)No-
PATHstringPath used to perform config scanNo-

Permissions

ScopeAccessDescription
contentswriteGeneral repo operations by jobs
security-eventswriteUpload SARIF to code scanning
pull-requestswritePost a comment on the pull request

Notes

  • images-scan runs only if IMAGE is provided; config-scan runs only if PATH is provided
  • Uploads SARIF results to the Security tab; on pull requests, posts a comment linking to the Security panel when both IMAGE and PATH are set
  • Skips common directories via skip-dirs: **/node_modules in config scan

Example

yaml
jobs:
  vuln-scan:
    uses: this-is-tobi/github-workflows/.github/workflows/scan-trivy.yml@main
    with:
      IMAGE: ghcr.io/my-org/my-image:1.2.3
      PATH: ./

Sources

Take a look at the project sources.