|
1 | 1 | # EPS Copilot Instructions |
2 | 2 |
|
3 | | -This project contains copilot instruction files that are copied to each EPS repo as an initial instructions. |
| 3 | +This repository contains the shared GitHub Copilot instruction files used across EPS repositories, along with a composite GitHub Action that copies those files into a target repository and opens a pull request with the changes. |
4 | 4 |
|
5 | | -It also contains an action that are used to cepy the files to each repo |
| 5 | +## What this repository contains |
| 6 | + |
| 7 | +- Shared instruction files under `.github/instructions` |
| 8 | +- A shared `.github/copilot-instructions.md` |
| 9 | +- Shared prompts under `.github/prompts` |
| 10 | +- A composite GitHub Action defined in `action.yml` |
| 11 | + |
| 12 | +## Action overview |
| 13 | + |
| 14 | +The action is intended to be called from another repository. It: |
| 15 | + |
| 16 | +1. Checks out the calling repository at the requested base branch |
| 17 | +2. Checks out the central source repository at the requested ref |
| 18 | +3. Replaces the target repository's Copilot instruction files with the shared versions |
| 19 | +4. Creates a signed pull request containing the sync changes |
| 20 | + |
| 21 | +The action currently syncs content from `NHSDigital/eps-common-workflows`. |
| 22 | + |
| 23 | +## Files synced by the action |
| 24 | + |
| 25 | +The action copies the following paths into the calling repository: |
| 26 | + |
| 27 | +- `.github/instructions/general` |
| 28 | +- `.github/instructions/languages` |
| 29 | +- `.github/copilot-instructions.md` |
| 30 | +- `.github/prompts` |
| 31 | + |
| 32 | +Existing copies of those paths in the calling repository are removed before the new content is copied in. |
| 33 | + |
| 34 | +## Inputs |
| 35 | + |
| 36 | +| Input | Required | Default | Description | |
| 37 | +| --- | --- | --- | --- | |
| 38 | +| `common_workflows_ref` | No | `main` | Git ref to check out from the central source repository | |
| 39 | +| `calling_repo_base_branch` | No | `main` | Base branch in the calling repository that the pull request should target | |
| 40 | +| `CREATE_PULL_REQUEST_APP_ID` | Yes | None | GitHub App ID used to generate a token for pull request creation | |
| 41 | +| `CREATE_PULL_REQUEST_PEM` | Yes | None | GitHub App private key in PEM format | |
| 42 | + |
| 43 | +## Example usage |
| 44 | + |
| 45 | +```yaml |
| 46 | +name: Sync Copilot Instructions |
| 47 | + |
| 48 | +on: |
| 49 | + workflow_dispatch: |
| 50 | + schedule: |
| 51 | + - cron: '0 6 * * 1' |
| 52 | + |
| 53 | +jobs: |
| 54 | + sync-copilot-instructions: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + environment: create_pull_request |
| 57 | + permissions: |
| 58 | + contents: write |
| 59 | + pull-requests: write |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Sync shared instructions |
| 63 | + uses: NHSDigital/eps-copilot-instructions@95118f6746ca7081258cc7f651dca1c5bb7339f1 |
| 64 | + with: |
| 65 | + common_workflows_ref: main |
| 66 | + calling_repo_base_branch: main |
| 67 | + CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }} |
| 68 | + CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }} |
| 69 | +``` |
| 70 | +
|
| 71 | +## Pull request behavior |
| 72 | +
|
| 73 | +When changes are detected, the action creates a pull request with: |
| 74 | +
|
| 75 | +- Branch prefix: `copilot-instructions-sync` |
| 76 | +- Commit message: `Upgrade: [dependabot] - sync Copilot instructions` |
| 77 | +- Pull request title: `Upgrade: [dependabot] - sync Copilot instructions` |
| 78 | +- Signed commits enabled |
| 79 | +- Automatic branch cleanup enabled |
| 80 | + |
| 81 | +The pull request body includes the ref used for the sync. |
| 82 | + |
| 83 | +## Prerequisites |
| 84 | + |
| 85 | +Before using the action in a repository, ensure that https://github.com/NHSDigital/electronic-prescription-service-account-resources/blob/main/scripts/set_github_secrets.py has been run to create the environment and secrets |
| 86 | + |
| 87 | +## Notes |
| 88 | + |
| 89 | +- The action is implemented as a composite action in `action.yml` |
| 90 | +- It uses pinned action SHAs for its external action dependencies |
| 91 | +- The action opens a pull request instead of pushing directly to the base branch |
0 commit comments