Skip to content
php-forgePublic

About

Actions reusables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

139 Commits

Folders and files

Repository files navigation

PHP Forge

PHPForge - Reusable GitHub Actions


A comprehensive collection of reusable GitHub Actions and workflows specifically designed for PHP projects. Streamline your CI/CD pipeline with battle-tested, configurable workflows for testing, static analysis, and code quality checks.

Features

Feature Overview

Available Workflows

Testing Workflows

Quality Assurance Workflows

Utility Actions

Quick start

Composer Require Checker

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: composer-require-checker

jobs:
  dependency-check:
    uses: php-forge/actions/.github/workflows/composer-require-checker.yml@v1
    with:
      command-options: "--config-file=.composer-require-checker.json"

Easy Coding Standard

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: easy-coding-standards

jobs:
  coding-standards:
    uses: php-forge/actions/.github/workflows/ecs.yml@v1
    with:
      command-options: "check --ansi --no-progress-bar"
      php-version: '["8.4"]'

Infection Mutation Testing {#infection}

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: mutation-testing

jobs:
  mutation-testing:
    uses: php-forge/actions/.github/workflows/infection.yml@v2
    secrets:
      STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
    with:
      # Infection configuration
      command-options: "--threads=4 --min-msi=80"
      command-coverage-options: --with-uncovered
      # PHPStan integration
      phpstan: true

PHPUnit

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: build

jobs:
  phpunit:
    uses: php-forge/actions/.github/workflows/phpunit.yml@v1
    secrets:
      AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    with:
      # Composer settings
      composer-command: composer install --prefer-dist --no-progress
      # Coverage settings
      coverage-driver: pcov
      coverage-format: clover
      # PHP configuration
      extensions: mbstring, intl, pdo_sqlite
      ini-values: date.timezone='UTC', memory_limit=-1
      # Operating systems
      os: '["ubuntu-latest", "windows-2022"]'
      # PHP versions to test
      php-version: '["8.1", "8.2", "8.3", "8.4"]'
      # PHPUnit configuration
      phpunit-configuration: phpunit.xml
      phpunit-exclude-group: integration
      phpunit-group: unit

PHPUnit with Database

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: build-mysql

jobs:
  database-tests:
    uses: php-forge/actions/.github/workflows/phpunit-database.yml@v1
    secrets:
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    with:
      # Database configuration
      database-env: |
        {
          "MYSQL_ROOT_PASSWORD": "root",
          "MYSQL_DATABASE": "test"
        }
        database-health-cmd: "mysqladmin ping"
        database-health-retries: 3
        database-image: mysql
        database-port: 3306
        database-type: mysql
        database-versions: '["8.0", "8.4", "latest"]'
        extensions: pdo, pdo_mysql
        php-version: '["8.4"]'
        phpunit-group: mysql

Supported Databases:

Database Docker Image Default Port Health Check Command
MySQL mysql 3306 mysqladmin ping
PostgreSQL postgres 5432 pg_isready
SQL Server mcr.microsoft.com/mssql/server 1433 sqlcmd -Q "SELECT 1"
Oracle gvenzl/oracle-xe 1521 sqlplus -S / as sysdba

PHPStan Static Analysis

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: static-analysis

jobs:
  static-analysis:
    uses: php-forge/actions/.github/workflows/phpstan.yml@v1
    with:
      # PHPStan configuration
      configuration: phpstan.neon
      command-options: "analyse --error-format=checkstyle | cs2pr"
      # Environment
      php-version: '["8.4"]'
      tools: cs2pr

Testo

---
on:
  pull_request: &ignore-paths
    paths-ignore:
      - ".gitattributes"
      - ".gitignore"
      - "CHANGELOG.md"
      - "docs/**"
      - "README.md"

  push: *ignore-paths

name: build

jobs:
  testo:
    uses: php-forge/actions/.github/workflows/testo.yml@v3
    secrets:
      AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    with:
      # Composer settings
      composer-command: install
      # Coverage settings
      coverage-driver: pcov
      coverage-format: clover
      # PHP configuration
      extensions: mbstring, intl, pdo_sqlite
      php-ini-values: date.timezone='UTC', memory_limit=-1
      # Operating systems
      os: '["ubuntu-latest", "windows-2022"]'
      # PHP versions to test
      php-version: '["8.3", "8.4", "8.5"]'
      # Testo configuration
      testo-configuration: testo.php
      testo-suite: Unit
      testo-type: "!bench"

Linter

---
on:
  - pull_request
  - push

name: linter

jobs:
  linter:
    uses: php-forge/actions/.github/workflows/quality.yml@main
    permissions:
      contents: read
    # Optional configuration and ignore paths, including former .github/linters files.
    # with:
    #   actionlint-config: .github/linters/actionlint.yml
    #   codespell-config: .github/linters/.codespellrc
    #   codespell-ignore-words-file: .github/linters/codespell-ignored-words.txt
    #   editorconfig-checker-config: .github/linters/.editorconfig-checker.json
    #   markdownlint-config: .github/linters/.markdown-lint.yml
    #   prettier-config: .github/linters/.prettierrc
    #   prettier-ignore-path: .github/linters/.prettierignore
    #   yamllint-config: .github/linters/.yaml-lint.yml

Security

---
on:
  - pull_request
  - push

name: security

permissions:
  contents: read

jobs:
  security:
    uses: php-forge/actions/.github/workflows/security.yml@main
    permissions:
      contents: read
    # Optional configuration and ignore paths, including former .github/linters files.
    # with:
    #   gitleaks-config: .github/linters/.gitleaks.toml
    #   zizmor-config: .github/linters/zizmor.yml

OpenSSF Scorecard

---
on:
  branch_protection_rule:
  push:
    branches:
      - main
  schedule:
    - cron: "30 1 * * 6"

name: scorecard

permissions:
  contents: read

jobs:
  scorecard:
    uses: php-forge/actions/.github/workflows/scorecard.yml@main
    permissions:
      contents: read # Required to check out the repository.
      id-token: write # Required to sign published results with the GitHub OIDC token.
      security-events: write # Required to upload SARIF results to code scanning.
    # Optional token with read access, required by the Branch-Protection check for classic branch protection.
    secrets:
      SCORECARD_TOKEN: ${{ secrets.SCORECARD_TOKEN }}
    # Optional configuration.
    # with:
    #   file-mode: git
    #   publish-results: true
    #   upload-sarif: false # Private repositories without GitHub Code Security.
  • Scorecard analyzes the default branch only, so trigger the workflow with push on that branch and schedule.
  • file-mode defaults to git, so Scorecard also analyzes paths such as .github that .gitattributes marks with export-ignore. The default archive mode of the action reads the GitHub tarball and skips those paths, which hides workflows, the security policy and token permissions from the checks.
  • publish-results sends signed results to the OpenSSF Scorecard API, which replaces the weekly public scan and enables the badge and the viewer for public repositories. The API verifies the called workflow, so the job keeps a literal ubuntu-latest runner and only allowlisted steps.
  • upload-sarif sends the SARIF results to GitHub code scanning, which private repositories only provide with GitHub Code Security. Set it to false there, otherwise the upload fails with HTTP 403 after the Scorecard run and the artifact upload complete.
  • SCORECARD_TOKEN is optional. An unset secret expands to an empty string and the workflow falls back to github.token, which reads repository rulesets but not classic branch protection.
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/{owner}/{repo}/badge)](https://scorecard.dev/viewer/?uri=github.com/{owner}/{repo})

Note: YAML files should use 2-space indentation. This example shows correct YAML syntax - copy it to your .github/workflows/*.yml files as-is.

Package information

GitHub Release

Quality code

Quality OpenSSF Scorecard

Our social networks

Follow on X

License

License

About

Actions reusables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors