-
Notifications
You must be signed in to change notification settings - Fork 33
Allow limited public assembler builds on docs-builder #2379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
15e6ee5
fc05e7e
3b228a0
4ca1805
ed133bf
71dbdaf
ebf0abb
31f208e
f46f699
76643cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| name: assembler-preview | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: 'Pull Request number to build the assembler preview for' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
| id-token: write | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: assembler-preview-${{ inputs.pr_number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| PR_NUMBER: ${{ inputs.pr_number }} | ||
| ASSEMBLER_PREVIEW_PATH_PREFIX: ${{ github.repository }}/docs/${{ inputs.pr_number }} | ||
| steps: | ||
| - name: Get PR details | ||
| id: pr-details | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| result-encoding: json | ||
| script: | | ||
| const { owner, repo } = context.repo; | ||
| const prNumber = parseInt(process.env.PR_NUMBER, 10); | ||
| if (isNaN(prNumber) || prNumber <= 0) { | ||
| core.setFailed(`Invalid PR number: ${process.env.PR_NUMBER}`); | ||
| return; | ||
| } | ||
| try { | ||
| const { data: pr } = await github.rest.pulls.get({ | ||
| owner, | ||
| repo, | ||
| pull_number: prNumber, | ||
| }); | ||
| return { | ||
| sha: pr.head.sha, | ||
| ref: pr.head.ref, | ||
| base_ref: pr.base.ref, | ||
| }; | ||
| } catch (error) { | ||
| core.setFailed(`Failed to get PR #${prNumber}: ${error.message}`); | ||
| } | ||
| - name: Checkout PR | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ fromJSON(steps.pr-details.outputs.result).sha }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Create Deployment | ||
| uses: actions/github-script@v8 | ||
| id: deployment | ||
| with: | ||
| result-encoding: string | ||
| script: | | ||
| const { owner, repo } = context.repo; | ||
| const prNumber = process.env.PR_NUMBER; | ||
| const environment = 'assembler-preview'; | ||
| const task = `assembler-preview-${prNumber}`; | ||
| const deployment = await github.rest.repos.createDeployment({ | ||
| owner, | ||
| repo, | ||
| environment, | ||
| task, | ||
| ref: '${{ fromJSON(steps.pr-details.outputs.result).sha }}', | ||
| auto_merge: false, | ||
| transient_environment: true, | ||
| required_contexts: [], | ||
| }) | ||
| await github.rest.repos.createDeploymentStatus({ | ||
| deployment_id: deployment.data.id, | ||
| owner, | ||
| repo, | ||
| state: "in_progress", | ||
| log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | ||
| }) | ||
| return deployment.data.id | ||
| - name: Bootstrap Action Workspace | ||
| uses: elastic/docs-builder/.github/actions/bootstrap@main | ||
|
|
||
| - name: Build assembled documentation | ||
| id: assembler-build | ||
| run: | | ||
| yq -i ".environments.preview.path_prefix = \"${ASSEMBLER_PREVIEW_PATH_PREFIX}\"" config/assembler.yml | ||
| dotnet run --project src/tooling/docs-builder -- assemble --skip-private-repositories --environment preview | ||
| - uses: elastic/docs-builder/.github/actions/aws-auth@main | ||
|
|
||
| - name: Upload assembled docs to S3 | ||
| id: s3-upload | ||
| env: | ||
| AWS_RETRY_MODE: standard | ||
| AWS_MAX_ATTEMPTS: 6 | ||
| run: | | ||
| aws s3 sync .artifacts/assembly/${ASSEMBLER_PREVIEW_PATH_PREFIX} "s3://elastic-docs-v3-website-preview/${ASSEMBLER_PREVIEW_PATH_PREFIX}" --delete --no-follow-symlinks | ||
| aws cloudfront create-invalidation \ | ||
| --distribution-id EKT7LT5PM8RKS \ | ||
| --paths "/${ASSEMBLER_PREVIEW_PATH_PREFIX}" "/${ASSEMBLER_PREVIEW_PATH_PREFIX}/*" | ||
| - name: Update Deployment Status | ||
| if: always() && steps.deployment.outputs.result | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| await github.rest.repos.createDeploymentStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| deployment_id: ${{ steps.deployment.outputs.result }}, | ||
| state: "${{ steps.s3-upload.outcome == 'success' && 'success' || 'failure' }}", | ||
| environment_url: `https://docs-v3-preview.elastic.dev/${process.env.ASSEMBLER_PREVIEW_PATH_PREFIX}`, | ||
| log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,14 +63,14 @@ on: | |
| type: boolean | ||
| default: false | ||
| required: false | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert this file completely (the whitespace clean up is good but lets not make it part of this PR). |
||
|
|
||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
| id-token: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }} | ||
| cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }} | ||
|
|
@@ -79,7 +79,7 @@ jobs: | |
| match: | ||
| if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| permissions: | ||
| contents: none | ||
| deployments: none | ||
| pull-requests: none | ||
|
|
@@ -104,7 +104,7 @@ jobs: | |
| with: | ||
| ref_name: ${{ steps.merge-group-base-branch.outputs.base_ref }} | ||
| repository: ${{ github.repository }} | ||
|
|
||
| - name: Match for PR events | ||
| id: pr-check | ||
| if: contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name) | ||
|
|
@@ -117,7 +117,7 @@ jobs: | |
| run: | | ||
| echo "ref=${{ github.base_ref }}" | ||
| echo "repo=${{ github.repository }}" | ||
|
|
||
| - name: Match for push events | ||
| id: push-check | ||
| if: contains(fromJSON('["push"]'), github.event_name) | ||
|
|
@@ -130,7 +130,7 @@ jobs: | |
| run: | | ||
| echo "ref=${{ github.ref_name }}" | ||
| echo "repo=${{ github.repository }}" | ||
|
|
||
| - name: Debug outputs | ||
| run: | | ||
| echo "content-source-match: ${{ format('{0}{1}{2}', steps.pr-check.outputs.content-source-match, steps.push-check.outputs.content-source-match, steps.merge-group-check.outputs.content-source-match) }}" | ||
|
|
@@ -141,7 +141,7 @@ jobs: | |
|
|
||
| check: | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| needs: | ||
| - match | ||
| permissions: | ||
| contents: read | ||
|
|
@@ -236,7 +236,7 @@ jobs: | |
| deployments: write | ||
| id-token: write | ||
| pull-requests: none | ||
| outputs: | ||
| outputs: | ||
| deployment_result: ${{ steps.deployment.outputs.result }} | ||
| path_prefix: ${{ steps.generate-path-prefix.outputs.result }} | ||
| env: | ||
|
|
@@ -261,7 +261,7 @@ jobs: | |
| with: | ||
| ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Create Deployment | ||
| if: > | ||
| env.MATCH == 'true' | ||
|
|
@@ -408,7 +408,7 @@ jobs: | |
| ) | ||
| ) | ||
| uses: elastic/docs-builder/actions/validate-inbound-local@main | ||
|
|
||
| - name: 'Validate inbound links' | ||
| if: > | ||
| env.MATCH == 'true' | ||
|
|
@@ -444,7 +444,7 @@ jobs: | |
| ) | ||
| ) | ||
| uses: elastic/docs-builder/actions/validate-path-prefixes-local@main | ||
|
|
||
| - name: 'Validate local path prefixes against those claimed by global navigation.yml' | ||
| if: > | ||
| env.MATCH == 'true' | ||
|
|
@@ -526,7 +526,7 @@ jobs: | |
| needs: | ||
| - check | ||
| - build | ||
| permissions: | ||
| permissions: | ||
| contents: none | ||
| deployments: none | ||
| id-token: none | ||
|
|
@@ -619,7 +619,7 @@ jobs: | |
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
|
|
||
|
|
||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner, repo, issue_number: prNum | ||
| }); | ||
|
|
@@ -656,7 +656,7 @@ jobs: | |
| ### 🤔 Need help? | ||
| - Check out the [cumulative docs guidelines](https://www.elastic.co/docs/contribute-docs/how-to/cumulative-docs/) | ||
| - Reach out in the [#docs](https://elastic.slack.com/archives/C0JF80CJZ) Slack channel`; | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner, repo, | ||
| issue_number: prNum, | ||
|
|
@@ -684,7 +684,7 @@ jobs: | |
| persist-credentials: false | ||
| - name: Run Vale Linter | ||
| uses: elastic/vale-rules/lint@main | ||
| with: | ||
| with: | ||
| files: ${{ needs.check.outputs.all_changed_files }} | ||
| - name: Post Vale Results | ||
| uses: elastic/vale-rules/report@main | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ public class LlmMarkdownExporter : IMarkdownExporter | |
|
|
||
| public async ValueTask<bool> FinishExportAsync(IDirectoryInfo outputFolder, Cancel ctx) | ||
| { | ||
| var outputDirectory = Path.Combine(outputFolder.FullName, "docs"); | ||
| var outputDirectory = outputFolder.FullName; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We expose llm.zip on elastic.co so I think this needs to be put under docs again. |
||
| var zipPath = Path.Combine(outputDirectory, "llm.zip"); | ||
|
|
||
| // Create the llms.txt file with boilerplate content | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ public void Generate() | |
|
|
||
| doc.Add(root); | ||
|
|
||
| using var fileStream = fileSystem.File.Create(Path.Combine(outputFolder.ToString() ?? string.Empty, "docs", "sitemap.xml")); | ||
| using var fileStream = fileSystem.File.Create(fileSystem.Path.Combine(outputFolder.FullName, "sitemap.xml")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sitemap.xml has to live under |
||
| doc.Save(fileStream); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs PR and label triggers