# GitHub Actions ヘルパー

GitHub Actions ワークフローを生成して改善します。

> \[!NOTE]
>
> * このライブラリの例はインスピレーションを得るためのものです。プロジェクト、言語、チーム プロセスに合わせて具体的に調整することをお勧めします。
> * 特定の言語とシナリオ向けのカスタム指示のコミュニティに投稿された例については、[Awesome GitHub Copilot Customizations](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md) リポジトリを参照してください。
> * カスタム指示は、作成するプラットフォームまたは IDE に応じて、さまざまなスコープにわたって適用できます。 詳しくは、「[GitHub Copilotの応答をカスタマイズする方法](/ja/copilot/concepts/response-customization)」を参照してください。

次の例は、`actions.instructions.md` フィールドを使用して、リポジトリ内の GitHub Actions ワークフロー ファイルにのみ適用されるパス固有の `applyTo` ファイルを示しています。 パス固有の手順ファイルの詳細については、「[GitHub Copilot用のリポジトリカスタム命令の追加](/ja/copilot/how-tos/configure-custom-instructions/add-repository-instructions#using-one-or-more-instructionsmd-files)」を参照してください。

````text copy
---
applyTo: ".github/workflows/**/*.yml"
---

When generating or improving GitHub Actions workflows:

## Security First
- Use GitHub secrets for sensitive data, never hardcode credentials
- Pin third-party actions to specific commits by using the SHA value (e.g., `- uses: owner/some-action@a824008085750b8e136effc585c3cd6082bd575f`)
- Configure minimal permissions for GITHUB_TOKEN required for the workflow

## Performance Essentials
- Cache dependencies with `actions/cache` or built-in cache options
- Add `timeout-minutes` to prevent hung workflows
- Use matrix strategies for multi-environment testing

## Best Practices
- Use descriptive names for workflows, jobs, and steps
- Include appropriate triggers: `push`, `pull_request`, `workflow_dispatch`
- Add `if: always()` for cleanup steps that must run regardless of failure

## Example Pattern
```yaml
name: CI
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm test
```
````

## 参考資料

* [GitHub Copilotの応答をカスタマイズする方法](/ja/copilot/concepts/response-customization) - GitHub Copilot での応答カスタマイズの概要
* [Copilot に対してカスタム命令を追加する](/ja/copilot/how-tos/configure-custom-instructions) - カスタム指示を構成する方法
* [優れた GitHub Copilot カスタマイズ](https://github.com/github/awesome-copilot/blob/main/README.md) - 特定の言語とシナリオ向けにコミュニティに投稿されたカスタム指示とその他のカスタマイズのリポジトリ