Repository navigation
64 lines (59 loc) · 2.44 KB
/
Copy pathprompt_changes.yml
File metadata and controls
64 lines (59 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Prompt change visibility
on:
pull_request:
branches:
- main
- develop
- 'release/**'
# `edited` also covers a change of base branch, which the check diffs against.
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
permissions:
contents: read
pull-requests: read
# A burst of label changes needs only the run for the last one.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
require-prompt-label:
runs-on: ubuntu-latest
outputs:
prompt_templates_changed: ${{ steps.prompt_files.outputs.changed }}
steps:
- name: Check whether bundled prompt changes are marked for release notes
id: prompt_files
uses: actions/github-script@v7
with:
script: |
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
per_page: 100,
});
const isBundledTemplate = (path) =>
typeof path === 'string' &&
path.startsWith('openrag/prompts/templates/') && path.endsWith('.txt');
const changesPrompt = files.some(({ filename, previous_filename }) =>
[filename, previous_filename].some(isBundledTemplate)
);
core.setOutput('changed', changesPrompt);
const labels = new Set(context.payload.pull_request.labels.map(({ name }) => name));
const hasLabel = labels.has('prompt');
if (changesPrompt && !hasLabel) {
core.setFailed('Bundled prompts changed. Add the prompt label so the release notes flag customized defaults for review.');
}
if (changesPrompt && labels.has('skip-changelog')) {
core.setFailed('Bundled prompt changes must appear in release notes; remove the skip-changelog label.');
}
check-released-prompt-seed-history:
name: Check released prompt seed history
needs: require-prompt-label
if: ${{ !cancelled() && needs.require-prompt-label.outputs.prompt_templates_changed == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check that previous bundled defaults remain refreshable
run: python3 scripts/check_prompt_seed_history.py "${{ github.event.pull_request.base.sha }}"