Skip to content

Commit cd1a1a3

Browse files
committed
use copilot sync action
1 parent f3d19a6 commit cd1a1a3

2 files changed

Lines changed: 14 additions & 104 deletions

File tree

.github/workflows/sync_copilot.yml

Lines changed: 14 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,23 @@
1-
name: Sync copilot instructions
1+
name: Sync Copilot Instructions
22

33
on:
4-
workflow_call:
5-
inputs:
6-
common_workflows_ref:
7-
description: "The ref to sync from the central repository"
8-
required: false
9-
default: "main"
10-
type: string
11-
calling_repo_base_branch:
12-
description: "The base branch from the calling repository that should be merged into"
13-
required: false
14-
type: string
15-
default: main
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 6 * * 1"
167

178
jobs:
18-
sync:
19-
runs-on: ubuntu-22.04
20-
environment: "create_pull_request"
9+
sync-copilot-instructions:
10+
runs-on: ubuntu-latest
11+
environment: create_pull_request
2112
permissions:
22-
contents: read
13+
contents: write
2314
pull-requests: write
2415

2516
steps:
26-
- name: Checkout calling repo code
27-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
17+
- name: Sync shared instructions
18+
uses: NHSDigital/eps-copilot-instructions@initial_instructions
2819
with:
29-
ref: ${{ inputs.calling_repo_base_branch }}
30-
fetch-depth: 0
31-
32-
- name: Checkout central repo code
33-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
34-
with:
35-
ref: ${{ inputs.common_workflows_ref }}
36-
fetch-depth: 0
37-
path: eps-common-workflows
38-
repository: NHSDigital/eps-common-workflows
39-
sparse-checkout: |
40-
.github/instructions/general
41-
.github/instructions/languages
42-
.github/copilot-instructions.md
43-
.github/prompts
44-
45-
- name: Copy central instructions
46-
run: |
47-
rm -rf .github/instructions/general
48-
rm -rf .github/instructions/languages
49-
rm -rf .github/copilot-instructions.md
50-
rm -rf .github/prompts
51-
mkdir -p .github/instructions/
52-
cp -R eps-common-workflows/.github/instructions/general .github/instructions/general
53-
cp -R eps-common-workflows/.github/instructions/languages .github/instructions/languages
54-
cp eps-common-workflows/.github/copilot-instructions.md .github/copilot-instructions.md
55-
cp -R eps-common-workflows/.github/prompts .github/prompts
56-
rm -rf eps-common-workflows
57-
58-
- name: Create GitHub App Token
59-
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
60-
id: generate-token
61-
with:
62-
app-id: "${{ secrets.CREATE_PULL_REQUEST_APP_ID }}"
63-
private-key: "${{ secrets.CREATE_PULL_REQUEST_PEM }}"
64-
65-
- name: Create Pull Request
66-
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
67-
with:
68-
token: "${{ steps.generate-token.outputs.token }}"
69-
commit-message: "Upgrade: [dependabot] - sync Copilot instructions"
70-
title: "Upgrade: [dependabot] - sync Copilot instructions"
71-
body: |
72-
Syncing Copilot instructions from central repo.
73-
Ref: `${{ inputs.common_workflows_ref }}`
74-
branch: copilot-instructions-sync
75-
base: ${{ inputs.calling_repo_base_branch }}
76-
branch-suffix: random
77-
sign-commits: true
78-
delete-branch: true
20+
common_workflows_ref: main
21+
calling_repo_base_branch: main
22+
CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }}
23+
CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }}

README.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ The workflows that are available to use are
88

99
- [Combine Dependabot PRs](#combine-dependabot-prs)
1010
- [Dependabot Auto Approve and Merge](#dependabot-auto-approve-and-merge)
11-
- [Sync copilot instructions](#sync-copilot-instructions)
1211
- [PR Title Check](#pr-title-check)
1312
- [Get Repo Config](#get-repo-config)
1413
- [Quality Checks](#quality-checks)
@@ -110,40 +109,6 @@ jobs:
110109
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
111110
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
112111
```
113-
## Sync copilot instructions
114-
This workflow syncs Copilot instructions from this repo into another repo and opens a PR with the changes.
115-
It uses the environment secrets CREATE_PULL_REQUEST_APP_ID and CREATE_PULL_REQUEST_PEM that are defined in the create_pull_request environment in each repo
116-
117-
#### Inputs
118-
119-
- `common_workflows_ref`: Branch in common workflows repo to sync from. Default: `main`
120-
- `calling_repo_base_branch`: The base branch in the calling repository. Default: `main`.
121-
122-
123-
124-
#### Example
125-
126-
```yaml
127-
name: Sync Copilot Instructions
128-
129-
on:
130-
workflow_dispatch:
131-
inputs:
132-
common_workflows_ref:
133-
description: "Branch to sync from"
134-
required: false
135-
type: string
136-
default: main
137-
138-
jobs:
139-
sync-copilot:
140-
uses: NHSDigital/eps-common-workflows/.github/workflows/sync_copilot.yml@f5c8313a10855d0cc911db6a9cd666494c00045a
141-
with:
142-
ref: ${{ github.event.inputs.common_workflows_ref }}
143-
secrets:
144-
CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }}
145-
CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }}
146-
```
147112
## PR Title Check
148113
This workflow checks that all pull requests have a title that matches the required format, and comments on the PR with a link to the relevant ticket if a ticket reference is found.
149114

0 commit comments

Comments
 (0)