{"meta":{"title":"GitHub Actions 帮助程序","intro":"生成并改进 GitHub Actions 工作流。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/copilot","title":"GitHub Copilot"},{"href":"/zh/copilot/tutorials","title":"教程"},{"href":"/zh/copilot/tutorials/customization-library","title":"定制化库"},{"href":"/zh/copilot/tutorials/customization-library/custom-instructions","title":"自定义说明"},{"href":"/zh/copilot/tutorials/customization-library/custom-instructions/github-actions-helper","title":"GitHub Actions 帮助程序"}],"documentType":"article"},"body":"# GitHub Actions 帮助程序\n\n生成并改进 GitHub Actions 工作流。\n\n> \\[!NOTE]\n>\n> * 此库中的示例旨在提供灵感，建议进行相应调整，使其更特定于你的项目、语言和团队流程。\n> * 如需获取社区提供的有关特定语言和场景的自定义指令示例，请参阅[出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md)仓库。\n> * 可以跨不同范围应用自定义指令，具体取决于要在其中创建自定义指令的平台或 IDE。 有关详细信息，请参阅“[关于自定义GitHub Copilot 响应](/zh/copilot/concepts/response-customization)”。\n\n以下示例使用 `actions.instructions.md` 字段显示了特定于路径的 `applyTo` 文件，该文件仅适用于仓库中的 GitHub Actions 工作流文件。 有关特定于路径的说明文件的详细信息，请参阅 [为GitHub Copilot添加存储库自定义说明](/zh/copilot/how-tos/configure-custom-instructions/add-repository-instructions#using-one-or-more-instructionsmd-files)。\n\n````text copy\n---\napplyTo: \".github/workflows/**/*.yml\"\n---\n\nWhen generating or improving GitHub Actions workflows:\n\n## Security First\n- Use GitHub secrets for sensitive data, never hardcode credentials\n- Pin third-party actions to specific commits by using the SHA value (e.g., `- uses: owner/some-action@a824008085750b8e136effc585c3cd6082bd575f`)\n- Configure minimal permissions for GITHUB_TOKEN required for the workflow\n\n## Performance Essentials\n- Cache dependencies with `actions/cache` or built-in cache options\n- Add `timeout-minutes` to prevent hung workflows\n- Use matrix strategies for multi-environment testing\n\n## Best Practices\n- Use descriptive names for workflows, jobs, and steps\n- Include appropriate triggers: `push`, `pull_request`, `workflow_dispatch`\n- Add `if: always()` for cleanup steps that must run regardless of failure\n\n## Example Pattern\n```yaml\nname: CI\non: [push, pull_request]\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    timeout-minutes: 10\n    steps:\n      - uses: actions/checkout@v6\n      - uses: actions/setup-node@v4\n        with:\n          node-version: 20\n          cache: npm\n      - run: npm ci\n      - run: npm test\n```\n````\n\n## 其他阅读材料\n\n* [关于自定义GitHub Copilot 响应](/zh/copilot/concepts/response-customization) - GitHub Copilot 中的响应自定义概述\n* [为 Copilot 添加自定义说明](/zh/copilot/how-tos/configure-custom-instructions) - 如何配置自定义指令\n* [出色的 GitHub Copilot 自定义内容](https://github.com/github/awesome-copilot/blob/main/README.md) - 社区提供的自定义指令的仓库以及特定语言和场景的其他自定义内容"}