Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 13 additions & 68 deletions .github/workflows/sync_copilot.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,23 @@
name: Sync copilot instructions
name: Sync Copilot Instructions

on:
workflow_call:
inputs:
common_workflows_ref:
description: "The ref to sync from the central repository"
required: false
default: "main"
type: string
calling_repo_base_branch:
description: "The base branch from the calling repository that should be merged into"
required: false
type: string
default: main
workflow_dispatch:
schedule:
- cron: "0 6 * * 1"

jobs:
sync:
sync-copilot-instructions:
runs-on: ubuntu-22.04
environment: "create_pull_request"
environment: create_pull_request
permissions:
contents: read
contents: write
pull-requests: write

steps:
- name: Checkout calling repo code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Sync shared instructions
uses: NHSDigital/eps-copilot-instructions@08241b83de78b996e7796806be8435314e9f0b7a
with:
ref: ${{ inputs.calling_repo_base_branch }}
fetch-depth: 0

- name: Checkout central repo code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ inputs.common_workflows_ref }}
fetch-depth: 0
path: eps-common-workflows
repository: NHSDigital/eps-common-workflows
sparse-checkout: |
.github/instructions/general
.github/instructions/languages
.github/copilot-instructions.md
.github/prompts

- name: Copy central instructions
run: |
rm -rf .github/instructions/general
rm -rf .github/instructions/languages
rm -rf .github/copilot-instructions.md
rm -rf .github/prompts
mkdir -p .github/instructions/
cp -R eps-common-workflows/.github/instructions/general .github/instructions/general
cp -R eps-common-workflows/.github/instructions/languages .github/instructions/languages
cp eps-common-workflows/.github/copilot-instructions.md .github/copilot-instructions.md
cp -R eps-common-workflows/.github/prompts .github/prompts
rm -rf eps-common-workflows

- name: Create GitHub App Token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
id: generate-token
with:
app-id: "${{ secrets.CREATE_PULL_REQUEST_APP_ID }}"
private-key: "${{ secrets.CREATE_PULL_REQUEST_PEM }}"

- name: Create Pull Request
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
with:
token: "${{ steps.generate-token.outputs.token }}"
commit-message: "Upgrade: [dependabot] - sync Copilot instructions"
title: "Upgrade: [dependabot] - sync Copilot instructions"
body: |
Syncing Copilot instructions from central repo.
Ref: `${{ inputs.common_workflows_ref }}`
branch: copilot-instructions-sync
base: ${{ inputs.calling_repo_base_branch }}
branch-suffix: random
sign-commits: true
delete-branch: true
common_workflows_ref: main
calling_repo_base_branch: main
CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }}
CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }}
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ The workflows that are available to use are

- [Combine Dependabot PRs](#combine-dependabot-prs)
- [Dependabot Auto Approve and Merge](#dependabot-auto-approve-and-merge)
- [Sync copilot instructions](#sync-copilot-instructions)
- [PR Title Check](#pr-title-check)
- [Get Repo Config](#get-repo-config)
- [Quality Checks](#quality-checks)
Expand Down Expand Up @@ -110,40 +109,6 @@ jobs:
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
```
## Sync copilot instructions
This workflow syncs Copilot instructions from this repo into another repo and opens a PR with the changes.
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

#### Inputs

- `common_workflows_ref`: Branch in common workflows repo to sync from. Default: `main`
- `calling_repo_base_branch`: The base branch in the calling repository. Default: `main`.



#### Example

```yaml
name: Sync Copilot Instructions

on:
workflow_dispatch:
inputs:
common_workflows_ref:
description: "Branch to sync from"
required: false
type: string
default: main

jobs:
sync-copilot:
uses: NHSDigital/eps-common-workflows/.github/workflows/sync_copilot.yml@f5c8313a10855d0cc911db6a9cd666494c00045a
with:
ref: ${{ github.event.inputs.common_workflows_ref }}
secrets:
CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }}
CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }}
```
## PR Title Check
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.

Expand Down
Loading