-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (73 loc) · 2.39 KB
/
changeset-required.yml
File metadata and controls
82 lines (73 loc) · 2.39 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Changeset Required
on:
pull_request:
branches:
- development
types:
- opened
- synchronize
- reopened
- ready_for_review
- edited
permissions:
contents: read
pull-requests: write
concurrency:
group: release-plan-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
changeset-required:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Skip validation for automated release PRs
if: github.head_ref == 'release/next'
run: |
echo "Automated release PR detected; changeset validation is skipped." >> "$GITHUB_STEP_SUMMARY"
- name: Validate PR changeset
if: github.head_ref != 'release/next'
run: |
python3 tools/release.py validate-pr \
--base "${{ github.event.pull_request.base.sha }}" \
--head "${{ github.event.pull_request.head.sha }}"
- name: Build release preview
if: github.head_ref != 'release/next'
run: |
python3 tools/release.py preview --format markdown > .release-plan.md
cat .release-plan.md >> "$GITHUB_STEP_SUMMARY"
- name: Upsert PR comment
if: github.head_ref != 'release/next'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- st-lib-release-plan -->';
const body = `${marker}\n${fs.readFileSync('.release-plan.md', 'utf8')}`;
const owner = context.repo.owner;
const repo = context.repo.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find((comment) => comment.body && comment.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}