-
-
Notifications
You must be signed in to change notification settings - Fork 146
64 lines (56 loc) · 1.9 KB
/
Copy pathpending-release.yml
File metadata and controls
64 lines (56 loc) · 1.9 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: Pending Release Label
# When a PR merges, tag any issues referenced in its title/body with
# "Pending Release". Uses the find-linked-issues composite action since
# GitHub's own closingIssuesReferences only populates for PRs targeting the
# default branch — and ours target dev.
on:
pull_request:
types: [closed]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
label-linked-issues:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Find linked issues
id: linked
uses: ./.github/actions/find-linked-issues
with:
pr-number: ${{ github.event.pull_request.number }}
- name: Label linked issues with "Pending Release"
uses: actions/github-script@v7
env:
LINKED_ISSUES: ${{ steps.linked.outputs.issues }}
with:
script: |
const { owner, repo } = context.repo;
const issues = JSON.parse(process.env.LINKED_ISSUES);
if (issues.length === 0) return;
try {
await github.rest.issues.createLabel({
owner, repo,
name: 'Pending Release',
color: 'fbca04',
description: 'Fixed in code, awaiting release',
});
} catch (e) {
if (e.status !== 422) throw e; // 422 = already exists
}
for (const issue_number of issues) {
try {
await github.rest.issues.addLabels({
owner, repo, issue_number,
labels: ['Pending Release'],
});
} catch (e) {
core.warning(`Failed to label #${issue_number}: ${e.message}`);
}
}