Skip to content

Commit 3b2e768

Browse files
authored
Merge branch 'main' into feature/extensionless-urls
2 parents 6fa8dfe + 764e19a commit 3b2e768

File tree

128 files changed

+1963
-317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1963
-317
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: AWS Auth
2+
3+
description: |
4+
This is an opinionated action to authenticate with AWS.
5+
It will generate a role ARN based on the repository name and the AWS account ID.
6+
7+
inputs:
8+
aws_account_id:
9+
description: 'The AWS account ID to generate the role ARN for'
10+
required: true
11+
default: '197730964718' # elastic-web
12+
aws_region:
13+
description: 'The AWS region to use'
14+
required: false
15+
default: 'us-east-1'
16+
aws_role_name_prefix:
17+
description: 'The prefix for the role name'
18+
required: false
19+
default: 'elastic-docs-v3-preview-'
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Generate AWS Role ARN
25+
id: role_arn
26+
shell: python
27+
env:
28+
AWS_ACCOUNT_ID: ${{ inputs.aws_account_id }}
29+
ROLE_NAME_PREFIX: ${{ inputs.aws_role_name_prefix }}
30+
run: |
31+
import hashlib
32+
import os
33+
prefix = os.environ["ROLE_NAME_PREFIX"]
34+
m = hashlib.sha256()
35+
m.update(os.environ["GITHUB_REPOSITORY"].encode('utf-8'))
36+
hash = m.hexdigest()[:64-len(prefix)]
37+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
38+
f.write(f"result=arn:aws:iam::{os.environ["AWS_ACCOUNT_ID"]}:role/{prefix}{hash}")
39+
- name: Configure AWS Credentials
40+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
41+
with:
42+
role-to-assume: ${{ steps.role_arn.outputs.result }}
43+
aws-region: ${{ inputs.aws_region }}

.github/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
template: |
33
$CHANGES
44
5-
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
5+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
66
name-template: 'docs-builder $RESOLVED_VERSION'
77
tag-template: '$RESOLVED_VERSION'
88
change-template: '- $TITLE by @$AUTHOR in #$NUMBER'

.github/workflows/pr.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
permissions:
77
contents: read
88
packages: read
9+
id-token: write
10+
pull-requests: write
11+
deployments: write
912

1013
concurrency:
1114
group: ${{ github.workflow }}-${{ github.ref }}
@@ -32,8 +35,14 @@ jobs:
3235

3336
- name: Publish AOT
3437
run: ./build.sh publishbinaries
35-
36-
# we run our artifact directly please use the prebuild
37-
# elastic/docs-builder@main GitHub Action for all other repositories!
38-
- name: Build documentation
39-
run: .artifacts/publish/docs-builder/release/docs-builder
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: docs-builder-binary
42+
path: .artifacts/publish/docs-builder/release/docs-builder
43+
if-no-files-found: error
44+
retention-days: 1
45+
46+
preview:
47+
needs: build
48+
uses: ./.github/workflows/preview.yml
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: preview-cleanup
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
permissions:
8+
deployments: write
9+
id-token: write
10+
11+
jobs:
12+
cleanup:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: ./.github/actions/aws-auth
17+
- name: Delete s3 objects
18+
env:
19+
PR_NUMBER: ${{ github.event.pull_request.number }}
20+
run: |
21+
aws s3 rm "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --recursive
22+
23+
- name: Delete GitHub environment
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const { owner, repo } = context.repo;
28+
const deployments = await github.rest.repos.listDeployments({
29+
owner,
30+
repo,
31+
environment: `preview-${context.issue.number}`
32+
});
33+
for (const deployment of deployments.data) {
34+
await github.rest.repos.createDeploymentStatus({
35+
owner,
36+
repo,
37+
deployment_id: deployment.id,
38+
state: 'inactive',
39+
description: 'Marking deployment as inactive'
40+
});
41+
await github.rest.repos.deleteDeployment({
42+
owner,
43+
repo,
44+
deployment_id: deployment.id
45+
});
46+
}
47+
48+
49+

.github/workflows/preview.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: preview
2+
3+
on:
4+
workflow_call: ~
5+
6+
permissions:
7+
id-token: write
8+
pull-requests: write
9+
deployments: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Create Deployment
16+
uses: actions/github-script@v7
17+
id: deployment
18+
with:
19+
result-encoding: string
20+
script: |
21+
const { owner, repo } = context.repo;
22+
const deployment = await github.rest.repos.createDeployment({
23+
issue_number: context.issue.number,
24+
owner,
25+
repo,
26+
ref: context.payload.pull_request.head.ref,
27+
environment: `preview-${context.issue.number}`,
28+
description: `Preview deployment for PR ${context.issue.number}`,
29+
auto_merge: false,
30+
required_contexts: [],
31+
})
32+
await github.rest.repos.createDeploymentStatus({
33+
deployment_id: deployment.data.id,
34+
owner,
35+
repo,
36+
state: "in_progress",
37+
description: "Deployment created",
38+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
39+
})
40+
return deployment.data.id
41+
42+
- uses: actions/checkout@v4
43+
44+
- uses: actions/download-artifact@v4
45+
with:
46+
name: docs-builder-binary
47+
48+
# we run our artifact directly please use the prebuild
49+
# elastic/docs-builder@main GitHub Action for all other repositories!
50+
- name: Build documentation
51+
env:
52+
PR_NUMBER: ${{ github.event.pull_request.number }}
53+
run: |
54+
chmod +x ./docs-builder
55+
./docs-builder --strict --path-prefix "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"
56+
57+
- uses: ./.github/actions/aws-auth
58+
59+
- name: Upload to S3
60+
env:
61+
PR_NUMBER: ${{ github.event.pull_request.number }}
62+
run: |
63+
aws s3 sync .artifacts/docs/html "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --delete
64+
aws cloudfront create-invalidation --distribution-id EKT7LT5PM8RKS --paths "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}/*"
65+
66+
- name: Update deployment status
67+
uses: actions/github-script@v7
68+
if: steps.deployment.outputs.result
69+
with:
70+
script: |
71+
await github.rest.repos.createDeploymentStatus({
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
deployment_id: ${{ steps.deployment.outputs.result }},
75+
state: "success",
76+
description: "Deployment completed",
77+
environment_url: `https://docs-v3-preview.elastic.dev/${context.repo.owner}/${context.repo.repo}/pull/${context.issue.number}`,
78+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
79+
})
80+
81+
- name: Update Deployment Status on Failure
82+
if: failure() && steps.deployment.outputs.result
83+
uses: actions/github-script@v7
84+
with:
85+
script: |
86+
await github.rest.repos.createDeploymentStatus({
87+
owner: context.repo.owner,
88+
repo: context.repo.repo,
89+
deployment_id: ${{ steps.deployment.outputs.result }},
90+
state: "failure",
91+
description: "Deployment failed",
92+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
93+
})

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Options:
2525

2626
Commands:
2727
generate Converts a source markdown folder or file to an output folder
28-
serve Continuously serve a documentation folder at http://localhost:5000.
28+
serve Continuously serve a documentation folder at http://localhost:3000.
2929
File systems changes will be reflected without having to restart the server.
3030
```
3131

@@ -63,10 +63,10 @@ Through the `serve` command you can continuously and partially compile your docu
6363

6464
```bash
6565
docker run -v "./.git:/app/.git" -v "./docs:/app/docs" -v "./.artifacts:/app/.artifacts" \
66-
-p 8080:8080 ghcr.io/elastic/docs-builder:edge serve
66+
-p 3000:3000 ghcr.io/elastic/docs-builder:edge serve
6767
```
6868

69-
Each page is compiled on demand as you browse http://localhost:8080 and is never cached so changes to files and
69+
Each page is compiled on demand as you browse http://localhost:3000 and is never cached so changes to files and
7070
navigation will always be reflected upon refresh.
7171

7272
Note the docker image is `linux-x86` and will be somewhat slower to invoke on OSX due to virtualization.
@@ -147,7 +147,7 @@ This project uses [Semantic Versioning](https://semver.org/) and its version is
147147
automatically determined by [release-drafter](https://github.com/release-drafter/release-drafter)
148148
based on the labels of the pull requests merged into the `main` branch.
149149

150-
See the [release-drafter configuration](../.github/release-drafter.yml) for more details.
150+
See the [release-drafter configuration](./.github/release-drafter.yml) for more details.
151151

152152
## Creating a New Release
153153

@@ -157,9 +157,9 @@ create a draft release or update the existing draft release in the [Releases](ht
157157
To create a new release you need to publish the existing draft release created by release-drafter.
158158

159159
> [!IMPORTANT]
160-
> Make sure the [release-drafter workflow](../.github/workflows/release-drafter.yml) is finished before publishing the release.
160+
> Make sure the [release-drafter workflow](https://github.com/elastic/docs-builder/actions/workflows/release-drafter.yml) is finished before publishing the release.
161161

162162
> [!NOTE]
163-
> When a release is published, the [create-major-tag workflow](../.github/workflows/create-major-tag.yml)
163+
> When a release is published, the [create-major-tag workflow](./.github/workflows/create-major-tag.yml)
164164
> will force push a new major tag in the format `vX` where `X` is the major version of the release.
165165
> For example, if the release is `1.2.3` was published, the workflow will force push a new tag `v1` on the same commit.

docs-builder.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "build", "build\build.fsproj
5151
EndProject
5252
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "docs-assembler", "src\docs-assembler\docs-assembler.csproj", "{28350800-B44B-479B-86E2-1D39E321C0B4}"
5353
EndProject
54+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "authoring", "tests\authoring\authoring.fsproj", "{018F959E-824B-4664-B345-066784478D24}"
55+
EndProject
5456
Global
5557
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5658
Debug|Any CPU = Debug|Any CPU
@@ -89,6 +91,10 @@ Global
8991
{28350800-B44B-479B-86E2-1D39E321C0B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
9092
{28350800-B44B-479B-86E2-1D39E321C0B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
9193
{28350800-B44B-479B-86E2-1D39E321C0B4}.Release|Any CPU.Build.0 = Release|Any CPU
94+
{018F959E-824B-4664-B345-066784478D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+
{018F959E-824B-4664-B345-066784478D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+
{018F959E-824B-4664-B345-066784478D24}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+
{018F959E-824B-4664-B345-066784478D24}.Release|Any CPU.Build.0 = Release|Any CPU
9298
EndGlobalSection
9399
GlobalSection(NestedProjects) = preSolution
94100
{4D198E25-C211-41DC-9E84-B15E89BD7048} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
@@ -99,5 +105,6 @@ Global
99105
{CD2887E3-BDA9-434B-A5BF-9ED38DE20332} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
100106
{A2A34BBC-CB5E-4100-9529-A12B6ECB769C} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
101107
{28350800-B44B-479B-86E2-1D39E321C0B4} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
108+
{018F959E-824B-4664-B345-066784478D24} = {67B576EE-02FA-4F9B-94BC-3630BC09ECE5}
102109
EndGlobalSection
103110
EndGlobal

docs-builder.sln.DotSettings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:Boolean x:Key="/Default/UserDictionary/Words/=docset/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/UserDictionary/Words/=frontmatter/@EntryIndexedValue">True</s:Boolean>
34
<s:Boolean x:Key="/Default/UserDictionary/Words/=linenos/@EntryIndexedValue">True</s:Boolean>
4-
<s:Boolean x:Key="/Default/UserDictionary/Words/=literalinclude/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
5+
<s:Boolean x:Key="/Default/UserDictionary/Words/=literalinclude/@EntryIndexedValue">True</s:Boolean>
6+
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0060_0060inli/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Attributes
2+
3+
tbd
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# File structure
2+
3+
tbd

0 commit comments

Comments
 (0)