This repository contains a comprehensive set of reusable GitHub Actions workflows for building, testing, and publishing various types of applications and libraries.
To use these workflows in your project, create a workflow file in your repository's .github/workflows/ directory:
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
build_and_deploy:
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
actions: write # Required for workflow management
contents: write # Required for GitHub releases
packages: write # Required for Docker/GHCR publishing
security-events: write # Required for security scanning (SARIF uploads)
id-token: write # REQUIRED - Always needed (currently for npm Trusted Publishing, planned for future OIDC integrations)
with:
tool: npm
lint: "run lint"
test: "run test"
build_main: "run build"
artifact_path: "dist"
event_name: ${{ github.event_name }}
docker_meta: '[{"name":"my-app","file":"Dockerfile"}]'
libraries: "lib1,lib2"
library_path: "packages"
secrets: inheritImportant permissions:
id-token: writeis REQUIRED for all workflows - Currently used for npm, Python, and Rust Trusted Publishing (no NPM_TOKEN, UV_TOKEN, or CARGO_REGISTRY_TOKEN needed!), with plans to extend OIDC to other publishing workflows in the futuresecurity-events: writeis REQUIRED - Enables SARIF uploads to GitHub Security tab for centralized vulnerability tracking- Due to GitHub Actions limitations, these permissions must be set at the top-level calling workflow, regardless of which publishing workflows you use
- If using
release-itfor npm, add.release-it.jsonwith{"npm": {"skipChecks": true}}
The main orchestrator workflow that handles the complete CI/CD pipeline.
Key Features:
- ✅ Multi-language support (Node.js, Python, Rust, Java, Gradle, Bash)
- ✅ Triple-layer security scanning (pre-build source + post-build artifacts + post-publish verification)
- ✅ Automated testing and building
- ✅ Multi-platform publishing (Docker, npm, PyPI, crates.io, Firefox, Android)
- ✅ Conditional deployment based on branch and inputs
Required Inputs:
event_name: GitHub event name (required)
Optional Inputs:
tool: Build tool (npm, yarn, uv, cargo, ./gradlew, mvn, bash)lint: Linting commandtest: Test commandbuild_main: Build command for main branchartifact_path: Path to build artifactsdocker_meta: Docker metadata JSONlibraries: Comma-separated list of libraries to publishrust_version: Rust toolchain version (default: "stable")enable_clippy: Run Clippy linting for Rust (default: true)enable_rustfmt: Run Rustfmt checks for Rust (default: true)clippy_args: Additional Clippy arguments (default: "-- -D warnings")cargo_features: Cargo features to enable (e.g., "async,network")enable_security_scanning: Enable/disable security scanning (default: "true")semgrep_rules: Semgrep ruleset configuration (default: "auto")trivy_severity: Minimum severity threshold (default: "MEDIUM,HIGH,CRITICAL")trivy_exit_code: Fail build on vulnerabilities (default: "1")- And many more...
Core workflow for testing and building applications.
Features:
- ✅ Advanced dependency caching for faster builds (tool-specific cache keys)
- ✅ Multi-language toolchain setup
- ✅ Nx monorepo support
- ✅ Playwright E2E testing (supports .ts, .js, and .mjs config variants)
- ✅ Descriptive artifact upload suffixes for clarity
- ✅ Configurable timeouts (45 minutes)
Publishes Docker images to container registries.
Features:
- ✅ Multi-platform builds (linux/amd64, linux/arm64)
- ✅ Flexible registry support (GHCR, Docker Hub, private registries)
- ✅ Input validation for security
- ✅ Matrix builds for multiple images with fail-fast: false
- ✅ Timeout protection (30 minutes)
Publishes Node.js libraries to npm registry using Trusted Publishing (Provenance).
Features:
- ✅ Trusted Publishing: No NPM_TOKEN required - uses OpenID Connect (OIDC)
- ✅ Version comparison to prevent duplicate publishes
- ✅ Multi-library support
- ✅ Security: Input sanitization and validation
- ✅ Dry-run validation (catches errors before publish)
- ✅ Timeout protection (20 minutes)
Important: Requires id-token: write permission instead of NPM_TOKEN secret
Publishes Python packages to PyPI using uv and Trusted Publishing (Provenance).
Features:
- ✅ Trusted Publishing: No UV_TOKEN required - uses OpenID Connect (OIDC)
- ✅ UV package manager support
- ✅ Automatic dependency management
- ✅ Explicit artifact validation with clear error messages
- ✅ Timeout protection (15 minutes)
Important: Requires id-token: write permission instead of UV_TOKEN secret
Publishes Rust crates to crates.io using OIDC Trusted Publishing (RFC 3691).
Features:
- ✅ OIDC Trusted Publishing: No CARGO_REGISTRY_TOKEN required - uses OpenID Connect
- ✅ Uses
rust-lang/crates-io-auth-action@v1for authentication - ✅ Short-lived tokens (auto-revoked after workflow completion)
- ✅ Version deduplication via crates.io API
- ✅ Dry-run support for testing
- ✅ Configurable Rustfmt and Clippy with custom arguments
- ✅ Cargo dependency caching (registry, git, target)
- ✅ Feature flag support (optional cargo features)
- ✅ Timeout protection (15 minutes)
Important: Requires id-token: write permission and Trusted Publisher configuration on crates.io
Configuration:
with:
tool: cargo
rust_version: stable # Toolchain version
enable_rustfmt: true # Run rustfmt checks
enable_clippy: true # Run clippy linting
clippy_args: "-- -D warnings" # Clippy arguments
cargo_features: "async,network" # Optional featuresPublishes Firefox browser extensions to Mozilla Add-ons.
Features:
- ✅ Automated packaging (XPI creation)
- ✅ AMO (addons.mozilla.org) publishing
- ✅ Timeout protection (15 minutes)
Builds and releases Android APK files.
Features:
- ✅ Automated keystore generation and caching
- ✅ APK signing and alignment
- ✅ GitHub releases integration
- ✅ Timeout protection (30 minutes)
Creates GitHub releases with artifacts.
Features:
- ✅ Automatic version detection (Python projects)
- ✅ Configurable release tags
- ✅ Artifact attachment
- ✅ Timeout protection (10 minutes)
Aggregates and reports results from all publishing workflows.
Features:
- ✅ Comprehensive status tracking across all workflows
- ✅ Visual summary table with status indicators
- ✅ Published artifacts tracking and output
- ✅ Refactored from 90 lines to 30 lines (67% reduction) using helper functions
- ✅ Quick timeout (5 minutes)
Pre-build security layer that scans source code and dependencies before building.
Features:
- ✅ Semgrep SAST: Fast static analysis for all languages (configurable rulesets)
- ✅ Bandit: Python-specific source code security analysis
- ✅ pip-audit: Python dependency vulnerability scanning (official PyPA tool)
- ✅ npm/yarn audit: Node.js dependency vulnerability scanning
- ✅ SARIF uploads: Results appear in GitHub Security tab
- ✅ Fail-fast: Prevents building vulnerable code
- ✅ Timeout protection (15 minutes)
Configuration:
with:
enable_security_scanning: "true" # Enable/disable (default: enabled)
semgrep_rules: "auto" # auto, p/security-audit, p/owasp-top-ten, p/ciAll tools are 100% free and open source:
- ✅ No signup required, no usage limits
- ✅ Industry-standard tools used by major projects
- ✅ Active maintenance and community support
Pre-publish security layer that scans build artifacts before publishing.
Features:
- ✅ Trivy: Comprehensive filesystem scanner for packages and dependencies
- ✅ Grype: Alternative vulnerability scanner for redundancy
- ✅ Filesystem scanning: Scans artifacts from
artifact_path - ✅ Security summary tables: Visual vulnerability reports in workflow output
- ✅ Security gate: Blocks publishing of vulnerable artifacts
- ✅ Timeout protection (20 minutes)
Post-publish security layer that verifies published Docker images.
Features:
- ✅ Trivy: Scans published Docker images pulled from registry
- ✅ GHCR Authentication: Uses GitHub OIDC token for registry access
- ✅ Supply chain verification: Detects post-build tampering or vulnerabilities
- ✅ Multi-image support: Scans all published Docker images
- ✅ SARIF uploads: Results appear in GitHub Security tab
- ✅ Timeout protection (20 minutes)
Configuration:
with:
trivy_severity: "MEDIUM,HIGH,CRITICAL" # Severity threshold
trivy_exit_code: "1" # 0=warn only, 1=fail buildDefense-in-depth architecture:
- Pre-build (security-scan-source.yml): Scan code & dependencies → Prevent vulnerable builds
- Build (test-and-build.yml): Create artifacts
- Pre-publish (security-scan-artifacts.yml): Scan filesystem artifacts → Block vulnerable publishes
- Publish: Docker images, npm packages, PyPI packages, etc.
- Post-publish (post-publish-verification.yml): Verify published Docker images → Detect supply chain attacks ✅
IMPORTANT: The id-token: write permission is REQUIRED for all workflows, regardless of which publishing targets you use:
jobs:
build_and_deploy:
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - Always needed for OIDC (npm/Python Trusted Publishing + future integrations)
actions: write # Required for workflow management
contents: write # Required for GitHub releases
packages: write # Required for Docker/GHCR publishing
security-events: write # REQUIRED - For security scanning SARIF uploads
with:
tool: npm
# ... other inputsWhy are these permissions always required?
id-token: write:
- Currently used for npm, Python, and Rust Trusted Publishing (no NPM_TOKEN, UV_TOKEN, or CARGO_REGISTRY_TOKEN needed!)
- Planned for future OIDC integrations with other publishing targets (Docker registries, etc.)
- Due to GitHub Actions limitations, permissions cannot be conditionally granted in reusable workflows
- Must be set at the top-level calling workflow, even if you're not publishing to npm, PyPI, or crates.io
security-events: write:
- Required for uploading SARIF reports to GitHub Security tab
- Enables centralized security vulnerability tracking across repositories
- Provides detailed security findings for Semgrep, Bandit, Trivy, and Grype scans
- Cannot be conditionally granted in reusable workflows
Add these secrets to your repository settings based on your publishing targets:
# For Docker publishing
GITHUB_TOKEN: # Auto-provided by GitHub
# For npm publishing - NO NPM_TOKEN NEEDED!
# Uses Trusted Publishing (Provenance) with OIDC
# Requires: id-token: write permission (see above)
# For Python publishing - NO UV_TOKEN NEEDED!
# Uses Trusted Publishing (Provenance) with OIDC
# Requires: id-token: write permission (see above)
# For Rust/Cargo publishing - NO CARGO_REGISTRY_TOKEN NEEDED!
# Uses OIDC Trusted Publishing (RFC 3691)
# Requires: id-token: write permission (see above)
# For Firefox extensions
AMO_API_KEY: # Mozilla Add-ons API key
AMO_API_SECRET: # Mozilla Add-ons API secret
# For Android builds
ANDROID_STOREPASS: # Android keystore password
# For Nx Cloud (optional)
NX_CLOUD_ACCESS_TOKEN: # Nx Cloud access tokenWhen using release-it with Trusted Publishing, you need to configure it to skip npm's built-in checks since the workflow handles authentication via OIDC.
Create a .release-it.json file in your project root:
{
"npm": {
"skipChecks": true
}
}Why is this needed?
- Release-it normally checks for npm authentication before publishing
- With Trusted Publishing, authentication happens automatically via GitHub's OIDC token
skipChecks: truetells release-it to trust the workflow's authentication
project/
├── package.json
├── .release-it.json # Required for release-it + Trusted Publishing
├── src/
├── dist/
├── Dockerfile (optional)
└── .github/workflows/ci.yml
project/
├── package.json
├── src/
├── dist/
├── Dockerfile (optional)
└── .github/workflows/ci.yml
project/
├── pyproject.toml
├── uv.lock
├── src/
├── dist/
└── .github/workflows/ci.yml
project/
├── Cargo.toml
├── Cargo.lock
├── src/
│ ├── main.rs (binary)
│ └── lib.rs (library)
├── tests/
├── benches/
├── target/
└── .github/workflows/ci-cd.yml
project/
├── package.json
├── packages/
│ ├── lib1/package.json
│ └── lib2/package.json
├── apps/
└── nx.json
The npm publishing workflow generates and attests Software Bill of Materials (SBOM) for supply chain security:
- Automatic SBOM generation: Creates SBOM from package-lock.json/yarn.lock using CycloneDX
- Sigstore attestation: Signs SBOM with keyless signing via GitHub's OIDC (eliminates need for signing keys)
- Format support: SPDX (default) or CycloneDX formats
- Artifact retention: SBOM uploaded as workflow artifact with 90-day retention
- Verification: Consumers can verify attestations using
npm audit signatures
Configuration:
inputs:
enable_sbom_attestation: "true" # Enable/disable (default: enabled)
sbom_format: "spdx" # spdx or cyclonedx (default: spdx)Verifying SBOM attestations as a consumer:
# Download attestation bundle for a published package
npm audit signatures <package-name>
# View SBOM details
gh attestation verify oci://registry.npmjs.org/<namespace>/<package>@<version> \
--owner <github-org>Benefits:
- ✅ Supply chain transparency: Full visibility into all dependencies
- ✅ Vulnerability tracking: Quick querying against known malicious packages
- ✅ Compliance: Meet SLSA/SSDF regulatory requirements
- ✅ Incident response: Rapid impact analysis during supply chain attacks
100% free and open-source security tools - no signup, no limits, industry-standard:
Prevents vulnerable code from being built:
- ✅ Semgrep SAST: Fast static analysis for all languages
- Configurable rulesets: auto, p/security-audit, p/owasp-top-ten, p/ci
- Detects: SQL injection, XSS, hardcoded secrets, insecure patterns
- ✅ Bandit (Python): Source code security analysis for Python projects
- ✅ pip-audit (Python): Official PyPA tool for dependency vulnerability scanning
- ✅ npm/yarn audit (Node.js): Built-in dependency vulnerability scanning
Security gate before publishing:
- ✅ Trivy: Comprehensive filesystem vulnerability scanner
- Scans: Filesystem artifacts, packages, dependencies
- Configurable severity thresholds (UNKNOWN, LOW, MEDIUM, HIGH, CRITICAL)
- ✅ Grype: Redundant vulnerability scanner for additional coverage
- ✅ Security summary tables: Visual reports in workflow output
- ✅ SARIF uploads: Centralized findings in GitHub Security tab
Verifies published Docker images:
- ✅ Trivy: Scans published Docker images from registry
- Authenticates to GHCR using GitHub OIDC token
- Pulls and scans actual deployed images
- Detects post-build supply chain attacks
- ✅ SARIF uploads: Results appear in GitHub Security tab
- ✅ Multi-image support: Scans all published Docker images
with:
enable_security_scanning: "true" # Enable/disable (default: enabled)
semgrep_rules: "auto" # Semgrep ruleset
trivy_severity: "MEDIUM,HIGH,CRITICAL" # Severity threshold
trivy_exit_code: "1" # 0=warn only, 1=fail buildlint → security_scan_source → test_and_build → security_scan_artifacts → [publishing jobs] → post_publish_verification
✅ ✅ ✅ ✅ ✅ ✅
All jobs depend on successful security scans - vulnerable code cannot be published and published images are verified.
- ✅ Updated to latest action versions (checkout@v6, setup-node@v5)
- ✅ Minimal permissions (contents: read by default)
- ✅ Early secret validation with categorized exit codes
- ✅ Defense-in-depth security architecture
- ✅ JSON validation for Docker metadata
- ✅ Library name sanitization
- ✅ Path traversal prevention
- ✅ Minimal required permissions
- ✅ Secret-based conditional execution
- ✅ Artifact existence validation
- ✅ Optimized timeouts (5-60 minutes)
- ✅ Prevents runaway builds
- ✅ Resource usage optimization
- ✅ Optimized timeouts for faster feedback
- ✅ Conditional Playwright setup (only when needed)
- ✅ Comprehensive workflow summary with status reporting
- ✅ Refactored summary workflow (67% code reduction)
- ✅ Multi-language dependency caching
- ✅ Build tool caches (npm, pip, gradle, maven)
- ✅ Cross-platform cache keys
- ✅ Tool-specific cache keys for optimal isolation
- ✅ Branch-based deployment
- ✅ Artifact-dependent publishing
- ✅ Tool-specific optimizations
- ✅ Dependabot configuration for weekly GitHub Actions updates
- ✅ Automated security patch application
- ✅ Reduced manual maintenance burden
name: build and publish pipeline
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: external workflow
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - Always needed (npm Trusted Publishing + future OIDC)
actions: write # Required for workflow management
contents: write # Required for GitHub releases
packages: write # Required for Docker/GHCR publishing
security-events: write # Required for security scanning (SARIF uploads)
with:
tool: npm
lint: "run lint"
test: "run test"
build_main: "run build"
artifact_path: "dist"
library_path: "dist"
event_name: ${{ github.event_name }}Note: This example follows the pattern from /Coding/AI/n8n/nodes/toon which uses Trusted Publishing for npm.
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - Always needed (npm Trusted Publishing + future OIDC)
contents: read
packages: write # Required for Docker publishing to GHCR
security-events: write # Required for security scanning (SARIF uploads)
with:
tool: npm
build_main: "run build"
artifact_path: "dist"
docker_meta: '[{"name":"my-app","file":"Dockerfile"}]'
docker_namespace: "mycompany"
registry: "ghcr.io"
event_name: ${{ github.event_name }}uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - Always needed (Python Trusted Publishing)
contents: read
security-events: write # Required for security scanning (SARIF uploads)
with:
tool: uv
install: "sync"
lint: "run lint"
test: "run test"
build_main: "build"
artifact_path: "dist"
event_name: ${{ github.event_name }}name: CI/CD
on:
push:
branches:
- main
pull_request:
jobs:
build_and_publish:
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - For OIDC Trusted Publishing to crates.io
actions: write
contents: write
packages: write
security-events: write
with:
tool: cargo
artifact_path: target/release/my-crate
event_name: ${{ github.event_name }}
# Rust configuration (all optional - defaults shown)
rust_version: stable
enable_rustfmt: true
enable_clippy: true
clippy_args: "-- -D warnings"
# Security scanning
enable_security_scanning: "true"
# GitHub release configuration (optional)
publish_github_release: ${{ startsWith(github.ref, 'refs/tags/v') && 'true' || 'false' }}
release_tag: ${{ github.ref_name }}Note: Before first publish, configure Trusted Publisher on crates.io for your repository. No secrets required!
uses: tehw0lf/workflows/.github/workflows/build-test-publish.yml@main
permissions:
id-token: write # REQUIRED - Always needed
contents: read
security-events: write # Required for security scanning (SARIF uploads)
with:
tool: bash
install: "install.sh"
lint: "lint.sh"
test: "test.sh"
build_main: "build.sh"
artifact_path: "dist"
event_name: ${{ github.event_name }}graph TD
A[build-test-publish.yml] --> L[lint.yml]
A --> M[security-scan-source.yml]
A --> B[test-and-build.yml]
A --> N[security-scan-artifacts.yml]
A --> C[publish-docker-image.yml]
A --> D[publish-npm-libraries.yml]
A --> E[publish-python-libraries.yml]
A --> F[publish-firefox-extension.yml]
A --> G[release-android-apk.yml]
A --> H[release-github.yml]
A --> K[publish-crates-io.yml]
A --> O[post-publish-verification.yml]
A --> J[summarize-workflow.yml]
L --> M
M --> B
B --> N
N --> C
N --> D
N --> E
N --> F
N --> G
N --> H
N --> K
C --> O
O --> J
C --> I[External: check-artifact + download-artifact]
D --> I
E --> I
F --> I
G --> I
H --> I
K --> I
Execution order:
- lint - Validate all workflows with actionlint
- security-scan-source - Pre-build security scanning (Semgrep, Bandit, pip-audit, npm audit)
- test-and-build - Run tests and build artifacts
- security-scan-artifacts - Pre-publish security scanning (Trivy, Grype on filesystem artifacts)
- [publishing jobs] - Only execute if all security scans pass
- post-publish-verification - Verify published Docker images from registry
- summarize-workflow - Aggregate results and report status
- Build timeouts: Adjust timeout values in workflow files
- Cache misses: Check cache key patterns and dependencies
- Permission errors: Verify repository secrets and permissions
- Artifact not found: Ensure
artifact_pathis correctly set
Solution: Ensure id-token: write permission is set in your workflow:
permissions:
id-token: writeSolution: Add .release-it.json to skip npm checks when using Trusted Publishing:
{
"npm": {
"skipChecks": true
}
}Solution:
- Verify
id-token: writepermission is granted - Ensure your npm package is configured for Trusted Publishing on npmjs.com
- Check that your GitHub repository has access to npm's OIDC provider
Solution: Ensure security-events: write permission is granted:
permissions:
security-events: writeSolution:
- Check the security tab for specific findings
- Review Semgrep rules configuration (
semgrep_rulesinput) - For false positives, add
# nosemgrepcomments or adjust ruleset - Disable security scanning temporarily with
enable_security_scanning: "false"(not recommended)
Solution:
- Review vulnerabilities in the security tab or workflow output
- Update dependencies to patched versions
- Adjust severity threshold if needed:
trivy_severity: "CRITICAL"(less strict) - Set
trivy_exit_code: "0"to warn only (not recommended for production)
If you need to temporarily disable security scanning:
with:
enable_security_scanning: "false"Warning: Disabling security scanning removes critical protection against vulnerabilities. Only use this for testing or non-production workflows.
Enable debug logging by adding this secret:
ACTIONS_STEP_DEBUG: true- Fork the repository
- Create a feature branch
- Make your changes
- Test with a sample project
- Submit a pull request
This workflow collection is available under the MIT License.