tangled
alpha
login
or
join now
kitten.sh
/
graphql.web
0
fork
atom
Mirror: The spec-compliant minimum of client-side GraphQL.
0
fork
atom
overview
issues
pulls
pipelines
chore: Add discord-message action logging
kitten.sh
2 years ago
123f797a
c063ef66
+8
-15
1 changed file
expand all
collapse all
unified
split
.github
actions
discord-message
action.mjs
+8
-15
.github/actions/discord-message/action.mjs
···
11
11
const updatedDepsRe = /\n-\s*Updated dependencies[\s\S]+\n(\n\s+-[\s\S]+)*/gi;
12
12
const markdownLinkRe = /\[([^\]]+)\]\(([^\)]+)\)/g;
13
13
const creditRe = new RegExp(`Submitted by (?:undefined|${markdownLinkRe.source})`, 'ig');
14
14
-
const repeatedNewlineRe = /(\n[ ]*)+/g;
14
14
+
const repeatedNewlineRe = /(?:\n[ ]*)*(\n[ ]*)/g;
15
15
return input
16
16
.replace(titleRe, '')
17
17
.replace(updatedDepsRe, '')
···
19
19
if (!text || /@kitten|@JoviDeCroock/i.test(text)) return '';
20
20
return `Submitted by [${text}](${url})`;
21
21
})
22
22
-
.replace(markdownLinkRe, (_match, text, url) => {
23
23
-
return `[${text}](<${url}>)`;
24
24
-
})
25
25
-
.replace(repeatedNewlineRe, '\n')
22
22
+
.replace(markdownLinkRe, (_match, text, url) => `[${text}](<${url}>)`)
23
23
+
.replace(repeatedNewlineRe, (_match, text) => text ? ` ${text}` : '\n')
26
24
.trim();
27
25
};
28
26
29
27
async function getReleaseBody(name, version) {
30
28
const tag = `${name}@${version}`;
31
31
-
const result = await octokit.rest.repos.getReleaseByTag({
32
32
-
owner: 'urql-graphql',
33
33
-
repo: 'urql',
34
34
-
tag,
35
35
-
});
29
29
+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
30
30
+
const result = await octokit.rest.repos.getReleaseByTag({ owner, repo, tag });
36
31
37
32
const release = result.status === 200 ? result.data : undefined;
38
33
if (!release || !release.body) return;
···
66
61
.join('\n\n');
67
62
68
63
// Send message through a discord webhook or bot
69
69
-
const response = fetch(WEBHOOK_URL, {
64
64
+
const response = await fetch(WEBHOOK_URL, {
70
65
method: 'POST',
71
66
headers: {
72
67
'Content-Type': 'application/json',
···
75
70
});
76
71
77
72
if (!response.ok) {
78
78
-
console.log('Something went wrong while sending the discord webhook.');
79
79
-
return;
73
73
+
console.error('Something went wrong while sending the discord webhook.', response.status);
74
74
+
console.error(await response.text());
80
75
}
81
81
-
82
82
-
return response;
83
76
}
84
77
85
78
main().then().catch(console.error);