Skip to content

Commit a0d3938

Browse files
authored
Merge branch 'main' into feature/extensionless-urls
2 parents b752fcd + 9322e16 commit a0d3938

28 files changed

+5181
-29
lines changed

.github/actions/bootstrap/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@ runs:
3030
echo "Version Number: ${REPO_VERSION}"
3131
echo "REPO_VERSION=${REPO_VERSION}" >> $GITHUB_ENV
3232
echo "full-version=${REPO_VERSION}" >> $GITHUB_OUTPUT
33-
echo "major-version=$(echo ${REPO_VERSION} | cut -d"." -f1)" >> $GITHUB_OUTPUT
33+
echo "major-version=$(echo ${REPO_VERSION} | cut -d"." -f1)" >> $GITHUB_OUTPUT
34+
35+
- uses: actions/setup-node@v4
36+
with:
37+
cache: npm
38+
cache-dependency-path: src/Elastic.Markdown/package-lock.json
39+
node-version-file: .nvmrc
40+

.github/workflows/comment-on-asciidoc-changes.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ jobs:
4141
4242
- name: Error if .asciidoc files changed
4343
if: steps.check-files.outputs.any_changed == 'true'
44-
run: exit 1
44+
run: |
45+
echo '::error::It looks like this PR modifies one or more .asciidoc files. These files are being migrated to Markdown, and any changes merged now will be lost. See the https://elastic.github.io/docs-builder/migration/freeze/index.html for details.'
46+
exit 1

.github/workflows/pr.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,3 @@ jobs:
4242
path: .artifacts/publish/docs-builder/release/docs-builder
4343
if-no-files-found: error
4444
retention-days: 1
45-
46-
preview:
47-
needs: build
48-
uses: ./.github/workflows/preview.yml
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: preview-build
2+
3+
on:
4+
pull_request: ~
5+
workflow_call:
6+
inputs:
7+
strict:
8+
description: 'Treat warnings as errors'
9+
type: boolean
10+
default: true
11+
continue-on-error:
12+
description: 'Do not fail to publish if build fails'
13+
type: boolean
14+
required: false
15+
default: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Bootstrap Action Workspace
28+
if: github.repository == 'elastic/docs-builder'
29+
uses: ./.github/actions/bootstrap
30+
31+
# we run our artifact directly please use the prebuild
32+
# elastic/docs-builder@main GitHub Action for all other repositories!
33+
- name: Build documentation
34+
if: github.repository == 'elastic/docs-builder'
35+
env:
36+
PR_NUMBER: ${{ github.event.pull_request.number }}
37+
run: |
38+
dotnet run --project src/docs-builder -- --strict --path-prefix "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"
39+
40+
- name: Build documentation
41+
if: github.repository != 'elastic/docs-builder'
42+
uses: elastic/docs-builder@main
43+
continue-on-error: true
44+
with:
45+
prefix: "/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
46+
strict: true
47+
- name: Add pull request number to build
48+
env:
49+
PR_NUMBER: ${{ github.event.pull_request.number }}
50+
PR_REF: ${{ github.event.pull_request.head.sha }}
51+
run: |
52+
echo "${PR_NUMBER}" >> .artifacts/docs/html/pull_request_number.txt
53+
echo "${PR_REF}" >> .artifacts/docs/html/pull_request_ref.txt
54+
- uses: actions/upload-artifact@v4
55+
with:
56+
name: docs
57+
path: .artifacts/docs/html/

.github/workflows/preview-cleanup.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ on:
66
types: [closed]
77

88
permissions:
9+
contents: none
910
deployments: write
1011
id-token: write
11-
contents: read
1212

1313
jobs:
1414
destroy:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
1817
- uses: elastic/docs-builder/.github/actions/aws-auth@main
1918
- name: Delete s3 objects
2019
env:
@@ -46,6 +45,3 @@ jobs:
4645
deployment_id: deployment.id
4746
});
4847
}
49-
50-
51-
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: preview-deploy
2+
3+
on:
4+
workflow_call: ~
5+
workflow_run:
6+
workflows: [preview-build]
7+
types:
8+
- completed
9+
10+
permissions:
11+
contents: none
12+
id-token: write
13+
deployments: write
14+
actions: read
15+
16+
jobs:
17+
docs-deploy:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Download docs
21+
env:
22+
GH_TOKEN: ${{ github.token }}
23+
run: |
24+
gh run download ${{ github.event.workflow_run.id }} --name docs --repo "${GITHUB_REPOSITORY}"
25+
- name: Get PR data
26+
id: pull_request
27+
run: |
28+
echo "number=$(cat pull_request_number.txt)" >> "${GITHUB_OUTPUT}"
29+
echo "ref=$(cat pull_request_ref.txt)" >> "${GITHUB_OUTPUT}"
30+
31+
- name: Create Deployment
32+
uses: actions/github-script@v7
33+
id: deployment
34+
env:
35+
PR_NUMBER: ${{ steps.pull_request.outputs.number }}
36+
PR_REF: ${{ steps.pull_request.outputs.ref }}
37+
with:
38+
result-encoding: string
39+
script: |
40+
const { owner, repo } = context.repo;
41+
const deployment = await github.rest.repos.createDeployment({
42+
owner,
43+
repo,
44+
ref: process.env.PR_REF,
45+
environment: `docs-preview-${process.env.PR_NUMBER}`,
46+
auto_merge: false,
47+
required_contexts: [],
48+
})
49+
await github.rest.repos.createDeploymentStatus({
50+
deployment_id: deployment.data.id,
51+
owner,
52+
repo,
53+
state: "in_progress",
54+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
55+
})
56+
return deployment.data.id
57+
58+
- uses: elastic/docs-builder/.github/actions/aws-auth@main
59+
60+
- name: Upload to S3
61+
env:
62+
PR_NUMBER: ${{ steps.pull_request.outputs.number }}
63+
run: |
64+
aws s3 sync . "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --delete --exclude "pull_request_number.txt"
65+
aws cloudfront create-invalidation --distribution-id EKT7LT5PM8RKS --paths "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}/*"
66+
67+
- name: Update deployment status
68+
uses: actions/github-script@v7
69+
if: always() && steps.deployment.outputs.result
70+
with:
71+
script: |
72+
await github.rest.repos.createDeploymentStatus({
73+
owner: context.repo.owner,
74+
repo: context.repo.repo,
75+
deployment_id: ${{ steps.deployment.outputs.result }},
76+
state: "${{ job.status == 'success' && 'success' || 'failure' }}",
77+
environment_url: `https://docs-v3-preview.elastic.dev/${context.repo.owner}/${context.repo.repo}/pull/${{ steps.pull_request.outputs.number}}`,
78+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
79+
})

.github/workflows/preview.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ on:
44
workflow_call:
55
inputs:
66
strict:
7+
description: 'Treat warnings as errors'
78
type: boolean
89
default: true
10+
continue-on-error:
11+
description: 'Do not fail to publish if build fails'
12+
type: boolean
13+
required: false
14+
default: true # default for will be false after migration
915

1016
permissions:
1117
id-token: write
@@ -62,7 +68,7 @@ jobs:
6268
- name: Build documentation
6369
if: github.repository != 'elastic/docs-builder'
6470
uses: elastic/docs-builder@main
65-
continue-on-error: ${{ inputs.strict != 'true' }} # Will be removed after the migration phase
71+
continue-on-error: ${{ inputs.continue-on-error == 'true' }} # Will be removed after the migration phase
6672
with:
6773
prefix: "/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
6874
strict: ${{ inputs.strict }}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.13.1

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,29 @@ To test performance it's best to build the binary and run outside of docker:
137137
For reference here's the `markitpy-doc` docset (50k markdown files) currently takes `14s` vs `several minutes` compared to
138138
existing surveyed tools
139139

140+
# Local Development
141+
142+
## Preqrequisites
143+
144+
- [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
145+
- [Node.js 22.13.1 (LTS)](https://nodejs.org/en/blog/release/v22.13.1)
146+
147+
148+
## Continuously build all assets during development.
149+
150+
```shell
151+
./build.sh watch
152+
```
153+
154+
This will monitor code, cshtml template files & static files and reload the application
155+
if any changes.
156+
157+
Web assets are reloaded through `parcel watch` and don't require a recompilation.
158+
159+
Markdown files are refreshed automatically through livereload
160+
161+
Code or layout changes will relaunch the server automatically
162+
140163
# Release Process
141164

142165
This section outlines the process for releasing a new version of this project.

actions/publish/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
description: 'Treat warnings as errors'
1616
required: false
1717
continue-on-error:
18-
description: 'Treat warnings as errors'
18+
description: 'Do not fail to publish if build fails'
1919
required: false
2020
default: "false"
2121
private:

0 commit comments

Comments
 (0)