Skip to content

Commit 29df759

Browse files
authored
feat(github): restore legacy dsm (#1777)
1 parent fbe5ace commit 29df759

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

.github/workflows/dsm.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: DSM
22
on:
3-
schedule:
4-
# every day at 6:00 UTC (9:00 MSK)
5-
- cron: '0 6 * * MON-FRI'
63
workflow_dispatch:
74

85
jobs:

.github/workflows/dsm_legacy.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: DSM
2+
on:
3+
schedule:
4+
# every day at 6:00 UTC (9:00 MSK)
5+
- cron: "0 6 * * MON-FRI"
6+
workflow_dispatch:
7+
8+
jobs:
9+
comment:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/create-github-app-token@v1
13+
id: app-token
14+
with:
15+
app-id: ${{ vars.DSM_APP_ID }}
16+
private-key: ${{ secrets.DSM_APP_SECRET }}
17+
owner: ${{ github.repository_owner }}
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
token: ${{ steps.app-token.outputs.token }}
22+
23+
- name: Read template
24+
id: template
25+
uses: juliangruber/read-file-action@v1
26+
with:
27+
path: ./.github/ISSUE_TEMPLATE/dsm.md
28+
29+
- name: Echo template
30+
run: echo ${{ steps.template.outputs.content }}
31+
32+
- uses: actions/github-script@v7
33+
with:
34+
github-token: ${{ steps.app-token.outputs.token }}
35+
script: |
36+
const organization = `${{ github.repository_owner }}`;
37+
const team_slugs = ['dsm'];
38+
let body = function(){/*${{ steps.template.outputs.content }}*/}.toString().slice(13, -3);
39+
const opts = github.rest.issues.listForRepo.endpoint.merge({
40+
...context.issue,
41+
type: 'DSM',
42+
state: 'open'
43+
});
44+
45+
const members = [];
46+
47+
for (const team_slug of team_slugs) {
48+
const teams_response = await github.request("GET /orgs/{org}/teams/{team_slug}/members", {
49+
team_slug: team_slug,
50+
org: organization
51+
});
52+
53+
members.push(...teams_response.data.map((member) => member.login));
54+
};
55+
56+
const issues = await github.paginate(opts);
57+
58+
for (const issue of issues) {
59+
github.rest.issues.update({
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
issue_number: issue.number,
63+
state: 'closed'
64+
});
65+
};
66+
67+
body += `\n\n<details>\n\n${members.map((member) => `@${member}`).join(', ')}\n\n</details>`;
68+
69+
await github.rest.issues.create({
70+
title: `[DSM] ${new Date().toDateString()}`,
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
assignees: members,
74+
type: 'DSM',
75+
body,
76+
});

0 commit comments

Comments
 (0)