Skip to content

Commit 0a2afbc

Browse files
authored
Merge branch 'main' into feature/applies-to-tooltips
2 parents 5c8c61a + 67e4620 commit 0a2afbc

File tree

5 files changed

+108
-12
lines changed

5 files changed

+108
-12
lines changed

.github/workflows/preview-build.yml

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ on:
4343
type: string
4444
default: 'false'
4545
required: false
46+
disable-comments:
47+
description: 'Disable comments'
48+
type: boolean
49+
default: false
50+
required: false
4651

4752
permissions:
4853
id-token: write
4954
deployments: write
5055
contents: read
51-
pull-requests: read
56+
pull-requests: write
5257

5358
jobs:
5459
match:
@@ -231,6 +236,81 @@ jobs:
231236
aws cloudfront create-invalidation \
232237
--distribution-id EKT7LT5PM8RKS \
233238
--paths "${PATH_PREFIX}" "${PATH_PREFIX}/*"
239+
240+
- name: Comment on PR
241+
continue-on-error: true
242+
if: startsWith(github.event_name, 'pull_request') && inputs.disable-comments != 'true' && env.MATCH == 'true' && steps.deployment.outputs.result && steps.check-files.outputs.all_changed_files
243+
uses: actions/github-script@v7
244+
env:
245+
ALL_CHANGED_FILES: ${{ steps.check-files.outputs.all_changed_files }}
246+
with:
247+
script: |
248+
const title = '## 🔍 Preview links for changed docs'
249+
const changedMdFiles = process.env.ALL_CHANGED_FILES
250+
.split(/\s+/)
251+
.filter(i => i.endsWith('.md'))
252+
.filter(i => !i.includes('/_snippets/'));
253+
254+
if (changedMdFiles.length === 0) {
255+
return;
256+
}
257+
258+
const toLink = (file) => {
259+
const path = file
260+
.replace('docs/', '')
261+
.replace('/index.md', '')
262+
.replace('.md', '');
263+
return `[${file}](https://docs-v3-preview.elastic.dev${process.env.PATH_PREFIX}/${path})`;
264+
}
265+
266+
const links = changedMdFiles.map(toLink)
267+
268+
const body = [
269+
title,
270+
...links.slice(0, 10).map(i => `- ${i}`),
271+
]
272+
273+
if (links.length > 10) {
274+
body.push('<details>');
275+
body.push('<summary>More links …</summary>');
276+
body.push('');
277+
for (const link of links.slice(10, 100)) {
278+
body.push(`- ${link}`);
279+
}
280+
body.push('');
281+
body.push('</details>');
282+
}
283+
284+
if (links.length > 100) {
285+
body.push('');
286+
body.push(`<sub>In total, ${links.length} files changed.</sub>`);
287+
}
288+
289+
const owner = context.repo.owner;
290+
const repo = context.repo.repo;
291+
const issue_number = context.payload.pull_request.number;
292+
293+
// Post or update a single bot comment
294+
const { data: comments } = await github.rest.issues.listComments({
295+
owner, repo, issue_number
296+
});
297+
const existing = comments.find(c =>
298+
c.user.type === 'Bot' &&
299+
c.body.startsWith(title)
300+
);
301+
if (existing) {
302+
await github.rest.issues.updateComment({
303+
owner, repo,
304+
comment_id: existing.id,
305+
body: body.join('\n'),
306+
});
307+
} else {
308+
await github.rest.issues.createComment({
309+
owner, repo,
310+
issue_number,
311+
body:body.join('\n'),
312+
});
313+
}
234314
235315
- name: Update Link Index
236316
if: |

src/Elastic.Documentation.Configuration/Versions/Version.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public enum VersioningSystemId
8282
[Display(Name = "edot_php")]
8383
EdotPhp,
8484
[Display(Name = "edot_python")]
85-
EdotPython
85+
EdotPython,
86+
[Display(Name = "edot_cf_aws")]
87+
EdotCfAws
8688
}
8789

8890
[YamlSerializable]

src/Elastic.Documentation.Configuration/versions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ versioning_systems:
8585
edot_python:
8686
base: 1.0
8787
current: 1.3.0
88+
edot_cf_aws:
89+
base: 0.1
90+
current: 0.1.6
91+

src/Elastic.Markdown/Myst/Components/ApplicableToComponent.cshtml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,49 +177,55 @@
177177

178178
if (pa.ApmAgentRum is not null)
179179
{
180-
@RenderProduct("APM Agent RUM", "Application&nbsp;Performance&nbsp;Monitoring Agent for Real User Monitoring", VersioningSystemId.ApmAgentRum, pa.ApmAgentRum)
180+
@RenderProduct("APM Agent RUM", "Application&nbsp;Performance&nbsp;Monitoring Agent for Real&nbsp;User&nbsp;Monitoring", VersioningSystemId.ApmAgentRum, pa.ApmAgentRum)
181181
;
182182
}
183183

184184
if (pa.EdotIos is not null)
185185
{
186-
@RenderProduct("EDOT iOS", "Elastic&nbsp;Distributions of OpenTelemetry for iOS", VersioningSystemId.EdotIos, pa.EdotIos)
186+
@RenderProduct("EDOT iOS", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;iOS", VersioningSystemId.EdotIos, pa.EdotIos)
187187
;
188188
}
189189

190190
if (pa.EdotAndroid is not null)
191191
{
192-
@RenderProduct("EDOT Android", "Elastic&nbsp;Distributions of OpenTelemetry for Android", VersioningSystemId.EdotAndroid, pa.EdotAndroid)
192+
@RenderProduct("EDOT Android", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;Android", VersioningSystemId.EdotAndroid, pa.EdotAndroid)
193193
;
194194
}
195195

196196
if (pa.EdotDotnet is not null)
197197
{
198-
@RenderProduct("EDOT .NET", " Elastic&nbsp;Distributions of OpenTelemetry for .NET", VersioningSystemId.EdotDotnet, pa.EdotDotnet)
198+
@RenderProduct("EDOT .NET", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;.NET", VersioningSystemId.EdotDotnet, pa.EdotDotnet)
199199
;
200200
}
201201

202202
if (pa.EdotJava is not null)
203203
{
204-
@RenderProduct("EDOT Java", "Elastic&nbsp;Distributions of OpenTelemetry for Java", VersioningSystemId.EdotJava, pa.EdotJava)
204+
@RenderProduct("EDOT Java", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;Java", VersioningSystemId.EdotJava, pa.EdotJava)
205205
;
206206
}
207207

208208
if (pa.EdotNode is not null)
209209
{
210-
@RenderProduct("EDOT Node.js", "Elastic&nbsp;Distributions of OpenTelemetry for Node.js", VersioningSystemId.EdotNode, pa.EdotNode)
210+
@RenderProduct("EDOT Node.js", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;Node.js", VersioningSystemId.EdotNode, pa.EdotNode)
211211
;
212212
}
213213

214214
if (pa.EdotPhp is not null)
215215
{
216-
@RenderProduct("EDOT PHP", "Elastic&nbsp;Distributions of OpenTelemetry for PHP", VersioningSystemId.ApmAgentPhp, pa.EdotPhp)
216+
@RenderProduct("EDOT PHP", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;PHP", VersioningSystemId.ApmAgentPhp, pa.EdotPhp)
217217
;
218218
}
219219

220220
if (pa.EdotPython is not null)
221221
{
222-
@RenderProduct("EDOT Python", "Elastic&nbsp;Distributions of OpenTelemetry for Python", VersioningSystemId.EdotPython, pa.EdotPython)
222+
@RenderProduct("EDOT Python", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;Python", VersioningSystemId.EdotPython, pa.EdotPython)
223+
;
224+
}
225+
226+
if (pa.EdotCfAws is not null)
227+
{
228+
@RenderProduct("EDOT CF AWS", "Elastic&nbsp;Distribution of OpenTelemetry&nbsp;Cloud&nbsp;Forwarder for AWS", VersioningSystemId.EdotCfAws, pa.EdotCfAws)
223229
;
224230
}
225231
}

src/Elastic.Markdown/Myst/FrontMatter/ApplicableTo.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ public record ProductApplicability
174174

175175
[YamlMember(Alias = "edot_python")]
176176
public AppliesCollection? EdotPython { get; set; }
177+
178+
[YamlMember(Alias = "edot_cf_aws")]
179+
public AppliesCollection? EdotCfAws { get; set; }
177180
}
178181

179182
public class ApplicableToConverter : IYamlTypeConverter
@@ -185,7 +188,7 @@ public class ApplicableToConverter : IYamlTypeConverter
185188
"elasticsearch", "observability", "security",
186189
"ecctl", "curator",
187190
"apm_agent_android","apm_agent_dotnet", "apm_agent_go", "apm_agent_ios", "apm_agent_java", "apm_agent_node", "apm_agent_php", "apm_agent_python", "apm_agent_ruby", "apm_agent_rum",
188-
"edot_ios", "edot_android", "edot_dotnet", "edot_java", "edot_node", "edot_php", "edot_python"
191+
"edot_ios", "edot_android", "edot_dotnet", "edot_java", "edot_node", "edot_php", "edot_python", "edot_cf_aws"
189192
];
190193

191194
public bool Accepts(Type type) => type == typeof(ApplicableTo);
@@ -393,7 +396,8 @@ private static bool TryGetProductApplicability(Dictionary<object, object?> dicti
393396
{ "edot_java", a => productAvailability.EdotJava = a },
394397
{ "edot_node", a => productAvailability.EdotNode = a },
395398
{ "edot_php", a => productAvailability.EdotPhp = a },
396-
{ "edot_python", a => productAvailability.EdotPython = a }
399+
{ "edot_python", a => productAvailability.EdotPython = a },
400+
{ "edot_cf_aws", a => productAvailability.EdotCfAws = a }
397401
};
398402

399403
foreach (var (key, action) in mapping)

0 commit comments

Comments
 (0)