1
0
mirror of synced 2025-12-20 10:28:40 -05:00
Files
docs/content/copilot/tutorials/customization-library/custom-instructions/github-actions-helper.md
Siara 164e19962b Discovery landing page (#58174)
Co-authored-by: Claire W <78226508+crwaters16@users.noreply.github.com>
Co-authored-by: Anne-Marie <102995847+am-stead@users.noreply.github.com>
Co-authored-by: Jules <19994093+jules-p@users.noreply.github.com>
Co-authored-by: Jules Porter <jules-p@users.noreply.github.com>
Co-authored-by: hubwriter <hubwriter@github.com>
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
2025-10-29 18:30:03 +00:00

2.1 KiB

title, intro, versions, category, complexity, octicon, topics
title intro versions category complexity octicon topics
GitHub Actions helper Generate and improve {% data variables.product.prodname_actions %} workflows.
feature
copilot
Custom instructions
GitHub flows
Path-specific
Repository
Configure Copilot
Simple
book
Copilot
Actions

{% data reusables.copilot.customization-examples-note %}

The following example shows a path-specific actions.instructions.md file that applies only to {% data variables.product.prodname_actions %} workflow files in your repository, using the applyTo field. For more information about path-specific instructions files, see AUTOTITLE.

---
applyTo: ".github/workflows/**/*.yml"
---

When generating or improving {% data variables.product.prodname_actions %} workflows:

## Security First
- Use {% data variables.product.prodname_dotcom %} 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: {% data reusables.actions.action-checkout %}
      - uses: {% data reusables.actions.action-setup-node %}
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm test
```

{% data reusables.copilot.custom-instructions-further-reading %}