All articles
    Healthcare DevOps
    8 min read

    Building SaMD CI/CD Pipelines: IEC 62304 Static Analysis

    Build audit-ready SaMD CI/CD pipelines. Learn to automate IEC 62304 static analysis, configure deterministic quality gates, and meet FDA standards with GitHub Actions.

    By MedTechOps Team ·
    Building SaMD CI/CD Pipelines: IEC 62304 Static Analysis

    Article content

    In 2026, delivering Software as a Medical Device (SaMD) feels like running a sprint inside a regulatory labyrinth. Modern engineering leads want cloud-native velocity, automated testing, and daily deployments. However, compliance officers and regulatory bodies such as the FDA, notified bodies overseeing the EU MDR, and auditors inspecting against IEC 62304 and ISO 13485 require traceable verification, rigorous safety class classifications, and documented risk mitigations.

    Historically, this tension resulted in two-speed engineering: developers wrote code quickly in modern Git workflows, only to freeze codebases for months while Quality Assurance (QA) manually generated static analysis reports, traceability matrices, and verification signatures. Under current FDA cybersecurity guidance and rigorous IEC 62304 lifecycle expectations, that manual approach is dead on arrival. Engineering teams must institutionalize quality gates directly into their delivery mechanism.

    This technical guide details how engineering organizations can construct robust, continuous integration/continuous deployment (CI/CD) pipelines using GitHub Actions to automate IEC 62304 static code analysis (SAST), enforce deterministic gating, and maintain an audit-ready compliance posture without throttling developer sprint cycles.

    Deconstructing IEC 62304 Requirements for Static Code Analysis

    IEC 62304 establishes lifecycle requirements for medical device software. While it does not dictate specific tooling like GitHub Actions, SonarQube, or Coverity, it mandates strict software development processes tied to software safety classifications:

    • Class A: No injury or damage to health is possible.
    • Class B: Non-serious injury is possible.
    • Class C: Death or serious injury is possible.

    For Class B and Class C software, clauses 5.5.2 (Software Unit Verification) and 5.5.3 (Software Unit Acceptance Criteria) impose non-negotiable verification demands. Regulators expect that software units meet documented coding standards, exhibit low defect density, and avoid well-known memory safety vulnerabilities, race conditions, and injection flaws.

    Furthermore, under recent FDA cybersecurity directives (spurred by Section 524B of the FD&C Act), static code analysis must address common weaknesses (CWEs) and maintain verifiable records of software composition and vulnerability assessments. If your engineering workflows isolate QA reviews to pre-release phases, your organization risks costly audit findings and delayed 510(k) or De Novo clearance. Integrating automated static analysis via enterprise-grade DevOps and managed cloud infrastructure transforms compliance from a manual gatekeeper into automated telemetry.

    Core Architectural Blueprint: The Auditable GitHub Actions Pipeline

    To satisfy an ISO 13485-certified Quality Management System (QMS) and IEC 62304 audit trails, an automated CI/CD pipeline must deliver four architectural properties:

    1. Immutability and Traceability: Every pipeline execution must map deterministically to a specific Git commit SHA, software unit identifier, and QMS change request (e.g., Jira ticket or GitHub Issue).
    2. Fail-Closed Quality Gates: Builds must fail automatically if critical static analysis thresholds—such as SonarQube Quality Gates or Semgrep security rules—are breached.
    3. Tamper-Evident Artifact Generation: Analysis outputs, Software Bill of Materials (SBOMs), and static test logs must be preserved as signed build artifacts, not transient runner logs.
    4. Segregation of Duties (Part 11 / Annex 11 Compliance): Code modifications cannot bypass testing via unmonitored administrative overrides; branch protection rules must enforce dual-control approvals.

    Below is an architectural diagram outlining how developers, GitHub Actions runners, and automated SAST engines converge to produce compliant audit records:

    Pipeline Invariant: "No commit shall merge into protected mainline branches without passing cryptographic linting, static code verification, and automated vulnerability scanning correlated to an IEC 62304 Class B/C verification protocol."

    Production GitHub Actions Workflow: Automated SAST and Compliance Gating

    Here is an end-to-end, production-ready GitHub Actions workflow implementation. It runs static analysis, enforces a strict quality gate, scans for known Common Weakness Enumerations (CWEs), and exports a formal verification artifact intended for ingestion into your QMS Cloud and Device Ops Platform.

    name: "SaMD IEC 62304 Static Code Analysis & Gating"
    
    on:
      pull_request:
        branches: [ "main", "release/*" ]
      push:
        branches: [ "main" ]
    
    permissions:
      contents: read
      security-events: write
      pull-requests: write
    
    jobs:
      static-analysis:
        name: "IEC 62304 Static Unit Verification"
        runs-on: ubuntu-latest
        timeout-minutes: 30
    
        steps:
          - name: "Checkout Source Code"
            uses: actions/checkout@v4
            with:
              fetch-depth: 0 # Full history needed for baseline analysis
    
          - name: "Set up Analysis Environment"
            uses: actions/setup-node@v4
            with:
              node-version: '20'
              cache: 'npm'
    
          - name: "Install Dependencies"
            run: npm ci
    
          - name: "Execute Static Analysis Engine (SonarQube/SonarCloud)"
            uses: SonarSource/sonarqube-scan-action@v2.0.1
            env:
              SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
              SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
            with:
              args: >
                -Dsonar.projectKey=samd-core-engine
                -Dsonar.organization=medtech-ops
                -Dsonar.sources=src
                -Dsonar.tests=tests
                -Dsonar.coverage.exclusions=**/*.spec.ts,**/*.mock.ts
                -Dsonar.cpd.exclusions=**/*.dto.ts
    
          - name: "Enforce IEC 62304 Quality Gate"
            id: quality-gate
            uses: SonarSource/sonarqube-quality-gate-action@v1.1.0
            timeout-minutes: 5
            env:
              SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
    
          - name: "Execute Semgrep for MedTech OWASP & CWE Verification"
            run: |
              docker run --rm -v "${{ github.workspace }}:/src" returntocorp/semgrep:latest \
                semgrep scan --config=auto --config "p/cwe-top-25" --json --output=semgrep-report.json
    
          - name: "Package Verification Evidence for DHF"
            if: always()
            run: |
              mkdir -p compliance-evidence
              cp semgrep-report.json compliance-evidence/ || true
              echo "Commit SHA: ${{ github.sha }}" > compliance-evidence/metadata.txt
              echo "Triggered by: ${{ github.actor }}" >> compliance-evidence/metadata.txt
              echo "Timestamp: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> compliance-evidence/metadata.txt
              echo "Gate Status: ${{ steps.quality-gate.outputs.quality-gate-status }}" >> compliance-evidence/metadata.txt
    
          - name: "Upload Static Verification Artifact"
            uses: actions/upload-artifact@v4
            with:
              name: iec62304-static-verification-${{ github.sha }}
              path: compliance-evidence/
              retention-days: 90
    

    Defining Deterministic Quality Gates for Medical Software

    In standard commercial SaaS, a "Quality Gate" is often subjective. An engineering manager might allow minor code smells or lower coverage to hit a marketing deadline. In regulated SaMD environments, this flexibility invalidates the Design History File (DHF) and violates FDA 21 CFR 820.30(f) verification criteria.

    Your CI/CD quality gate rules in tools like SonarQube, Coverity, or Fortify must match the pre-specified acceptance criteria in your Software Development Plan (SDP). Typical baseline criteria for an IEC 62304 Class B/C product include:

    • Zero Blockers or Critical Vulnerabilities: Any CWE matching OWASP Top 10, SANS Top 25, or memory corruption patterns results in an immediate pipeline failure.
    • Code Coverage Thresholds: Minimum 80% line and branch coverage on modified code for Class B; minimum 90%+ for Class C units performing diagnostic algorithms.
    • Maintainability & Cyclomatic Complexity: Units with cyclomatic complexity exceeding 15 or cognitive complexity above 20 must be flagged for architectural refactoring before merge.
    • Zero Unreviewed Suppressions: Using inline comments like // NOSONAR or // eslint-disable must be blocked by pre-commit hooks or pipeline checks unless accompanied by an auditable waiver ID linked to a verified risk mitigation ticket.

    Handling False Positives Without Violating Regulatory Traceability

    Static analysis tools inevitably trigger false positives. In standard SaaS, developers simply mark them as "Won't Fix" directly in the dashboard. In SaMD, dismissals are regulatory decisions: you are formally asserting that a reported issue is not a risk to patient safety.

    To handle this legally and maintain sprint velocity, implement a triage protocol:

    1. The engineer creates a Jira/QMS ticket categorizing the false positive, providing justification based on system boundary mitigations.
    2. A Quality Engineer or designated Software Safety Officer approves the ticket.
    3. The suppression is committed using an annotated rule waiver file (e.g., .ruleset-suppressions.json) that references the ticket number, which the CI pipeline verifies during PR execution.

    Ensuring FDA 21 CFR Part 11 & ISO 13485 Audit-Readiness

    Automating static analysis execution is only half the battle. Auditors demand proof of data integrity and process validation:

    1. Automated Design History File (DHF) Population

    Do not export PDFs manually when preparing for an audit. Use CI actions to publish the JSON artifacts generated by your static analysis runs directly to an electronic QMS (eQMS) via secure Webhooks. When a GitHub Release tag is generated, aggregate all pipeline verification outputs into an automated Software Verification Report (SVR) referenced in your Device Master Record (DMR).

    2. CI/CD Tool Qualification (Computer Software Assurance - CSA)

    Under ISO 13485:2016 clause 4.1.6, tools used in the quality management system—which includes the CI/CD pipeline and static analysis engines—must be validated prior to initial use. Under FDA's CSA (Computer Software Assurance) guidance, you do not need to test every feature of GitHub Actions; focus instead on verifying its intended use:

    • Verify that the pipeline fails when an intentional flaw (e.g., a known buffer overflow or critical vulnerability) is introduced.
    • Verify that branch protection prevents unauthorized direct commits to production branches.
    • Document the pipeline's configuration as code within an audited Git repository.

    Need support establishing tool qualification protocols and compliant cloud infrastructure? Talk to our specialists via our engineering consultation team.

    Frequently Asked Questions (FAQ)

    Does IEC 62304 explicitly require static code analysis?

    IEC 62304 does not mandate a specific brand or method, but clause 5.5.2 mandates Software Unit Verification. For Class B and C devices, static analysis is considered standard practice by the FDA, notified bodies, and international regulators to demonstrate that software units conform to coding standards, maintain defensible architectural patterns, and avoid systemic software faults.

    How do we handle static analysis runs that take 45+ minutes?

    Long analysis runs degrade developer velocity. Optimize execution by splitting pipeline jobs: execute fast linters, formatters, and differential static analysis (scanning only touched lines and PR diffs) on pull requests. Run comprehensive, full-repository deep scans nightly or upon merge into integration branches, preventing bottlenecks during active sprint hours.

    Can self-hosted GitHub Actions runners be used in HIPAA-compliant pipelines?

    Yes. Many healthcare organizations run self-hosted runners within their own AWS or Azure Virtual Private Clouds (VPC). This guarantees that proprietary medical algorithms, protected codebases, and synthetic test datasets never traverse public multi-tenant environments. Ensure the runners are ephemeral, use dedicated IAM roles, and maintain automated audit logs.

    What happens if a developer bypasses a GitHub Action quality gate?

    In a regulated software environment, this constitutes a non-conformance. GitHub repository settings should eliminate bypass privileges entirely—even for Organization Owners. If an emergency hotfix requires a bypass, it must trigger an automated security event, alert the Quality Manager, and initiate a documented Corrective and Preventive Action (CAPA) or Deviation workflow within your QMS.

    Conclusion: Velocity and Compliance Are Not Mutually Exclusive

    Automating IEC 62304 static code analysis using GitHub Actions replaces unpredictable manual reviews with deterministic, repeatable engineering workflows. By codifying quality gates, enforcing branch protection, and automatically capturing verification evidence in your CI/CD pipelines, your team safeguards patient health, satisfies FDA scrutiny, and ships life-saving medical software on predictable timelines.

    Healthcare DevOps
    SaMD
    IEC 62304
    GitHub Actions
    FDA Compliance
    Static Code Analysis