Skip to content

Add a new job to handle push event matching #1279

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

Merged
merged 18 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ on:
branches:
- main
- master
# TODO remove these need to be added to individual repositories
- '\d+.\d+.\d+'
- '\d+.\d+'
- '\d+.x'
tags:
- 'v?\d+.\d+.\d+'
- 'v?\d+.\d+'
workflow_call:
inputs:
strict:
Expand Down Expand Up @@ -44,6 +51,39 @@ permissions:
pull-requests: read

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)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}
runs-on: ubuntu-latest
outputs:
content-source-match: ${{ steps.event-check.outputs.content-source-match != '' && steps.event-check.outputs.content-source-match || steps.match.outputs.content-source-match }}
content-source-name: ${{ steps.event-check.outputs.content-source-name != '' && steps.event-check.outputs.content-source-name || steps.match.outputs.content-source-name }}
steps:
- name: Not a push event
id: event-check
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
# ensure we emit static output to simplify our checks in the build step
run: |
echo "content-source-match=true" >> $GITHUB_OUTPUT
echo "content-source-name=next" >> $GITHUB_OUTPUT
- name: Match for push events
id: match
if: contains(fromJSON('["push"]'), github.event_name)
uses: elastic/docs-builder/actions/assembler-match@main
with:
ref_name: ${{ github.ref_name }}
repository: ${{ github.repository }}
- name: Debug
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
run: |
echo "Non sensitive data, echo'ing here temporarily to validate this job before connecting it further into the build job"
echo "content-source-match=${{ steps.event-check.outputs.content-source-match != '' && steps.event-check.outputs.content-source-match || steps.match.outputs.content-source-match }}"
echo "content-source-name=${{ steps.event-check.outputs.content-source-name != '' && steps.event-check.outputs.content-source-name || steps.match.outputs.content-source-name }}"
echo "ref=${{ github.ref_name }}"
echo "repo=${{ github.repository }}"

build:
if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
concurrency:
Expand All @@ -52,6 +92,7 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PR_REF_NAME: ${{ github.event.pull_request.head.ref }}
needs: [ match ]
steps:

- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions docs-builder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tooling", "tooling", "{73AB
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "authoring", "authoring", "{059E787F-85C1-43BE-9DD6-CE319E106383}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assembler-filter", "assembler-filter", "{FB1C1954-D8E2-4745-BA62-04DD82FB4792}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assembler-match", "assembler-match", "{FB1C1954-D8E2-4745-BA62-04DD82FB4792}"
ProjectSection(SolutionItems) = preProject
actions\assembler-filter\action.yml = actions\assembler-filter\action.yml
actions\assembler-match\action.yml = actions\assembler-match\action.yml
EndProjectSection
EndProject
Global
Expand Down
2 changes: 1 addition & 1 deletion src/tooling/docs-assembler/AssembleSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private AssembleSources(AssembleContext assembleContext, Checkout[] checkouts)
UriResolver = new PublishEnvironmentUriResolver(TocTopLevelMappings, assembleContext.Environment);
var crossLinkResolver = new CrossLinkResolver(crossLinkFetcher, UriResolver);
AssembleSets = checkouts
.Where(c => !c.Repository.Skip)
.Where(c => c.Repository is { Skip: false })
.Select(c => new AssemblerDocumentationSet(NullLoggerFactory.Instance, assembleContext, c, crossLinkResolver, TreeCollector))
.ToDictionary(s => s.Checkout.Repository.Name, s => s)
.ToFrozenDictionary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ private bool TryUpdateSource(string name, string branch, string relativePath, ID
return true;
}

private string CheckoutFromScratch(Repository repository, string name, string branch, string relativePath,
IDirectoryInfo checkoutFolder)
private string CheckoutFromScratch(Repository repository, string name, string branch, string relativePath, IDirectoryInfo checkoutFolder)
{
_logger.LogInformation("Checkout: {Name}\t{Branch}\t{RelativePath}", name, branch, relativePath);
switch (repository.CheckoutStrategy)
Expand Down
2 changes: 2 additions & 0 deletions src/tooling/docs-assembler/assembler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ references:
opentelemetry:
search-ui:
integration-docs:
docs-builder:
skip: true
Loading