
vimeo/psalm-github-actions本镜像包含 Psalm 的官方 GitHub Actions,用于在 GitHub Actions 工作流中运行 Psalm 静态代码分析工具。主要用途是在自动化流程中对 PHP 项目进行静态代码检查,检测代码中的错误、潜在问题及安全漏洞,提升代码质量与安全性。
适用于在 GitHub Actions 工作流中对 PHP 项目执行自动化静态代码分析的场景,尤其适合需要:
在 GitHub Actions 工作流中添加 Psalm 分析步骤,基础配置如下:
yamlname: Psalm Static Analysis on: [push, pull_request] jobs: psalm: name: Psalm runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Run Psalm uses: docker://ghcr.io/psalm/psalm-github-actions
可通过镜像标签指定 Psalm 版本(需 3.14.2 及以上版本):
yaml- name: Run Psalm uses: docker://ghcr.io/psalm/psalm-github-actions:5.7.7 # 指定版本为 5.7.7
启用安全分析并生成报告:
yaml- name: Run Psalm with Security Analysis uses: docker://ghcr.io/psalm/psalm-github-actions with: security_analysis: true # 启用安全分析
将安全分析结果以 SARIF 格式上传至 GitHub Security 标签,便于团队集中查看:
yaml- name: Run Psalm with Security Analysis uses: docker://ghcr.io/psalm/psalm-github-actions with: security_analysis: true report_file: results.sarif # 指定 SARIF 报告文件路径 - name: Upload Security Results to GitHub uses: github/codeql-action/upload-sarif@v2 with: sarif_file: results.sarif # 上传生成的 SARIF 文件
默认不安装 dev 依赖且检查平台要求,可通过以下配置修改:
yaml- name: Run Psalm with Custom Composer Config uses: docker://ghcr.io/psalm/psalm-github-actions with: composer_require_dev: true # 安装 dev 依赖(默认 false) composer_ignore_platform_reqs: true # 忽略平台要求(默认 false)
若 composer.json 不在项目根目录,可通过 relative_dir 指定相对路径:
yaml- name: Run Psalm in Subdirectory uses: docker://ghcr.io/psalm/psalm-github-actions with: relative_dir: ./subdir # Composer 文件所在的相对目录
访问私有 Composer 仓库需通过 SSH 认证,配置步骤如下:
yaml- name: Run Psalm with Private Repo Access uses: docker://ghcr.io/psalm/psalm-github-actions with: ssh_key: ${{ secrets.PRIVATE_SSH_KEY }} # 私有 SSH 密钥(必填) ssh_key_pub: ${{ secrets.PUBLIC_SSH_KEY }} # 公钥(必填) ssh_domain: my-custom-git.com # 自定义仓库域名(可选,默认支持 github.com、gitlab.com、bitbucket.org)
| 参数名 | 描述 | 类型 | 默认值 | 必填性 |
|---|---|---|---|---|
security_analysis | 是否启用安全分析 | bool | false | 可选 |
report_file | 安全分析报告文件路径(仅 security_analysis: true 时有效) | string | - | 可选 |
composer_require_dev | 是否安装 dev 依赖 | bool | false | 可选 |
composer_ignore_platform_reqs | 是否忽略 Composer 平台要求(如 PHP 版本、扩展) | bool | false | 可选 |
relative_dir | Composer 文件所在的相对目录 | string | ./ | 可选 |
ssh_key | 私有仓库 SSH 私钥(访问私有仓库时必填) | string | - | 私有仓库必填 |
ssh_key_pub | 私有仓库 SSH 公钥(访问私有仓库时必填) | string | - | 私有仓库必填 |
ssh_domain | 私有仓库域名(默认支持 github.com、gitlab.com、bitbucket.org) | string | - | 自定义域名时必填 |





manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务