diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 924bdf7f9..94804564d 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -36,36 +36,36 @@ jobs: build: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request_target' }} + cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }} runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + persist-credentials: false + - name: Get changed files - if: github.event_name == 'pull_request_target' + if: startsWith(github.event_name, 'pull_request') || github.event_name == 'merge_group' id: check-files uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6 with: files: ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }} - name: Free Disk Space + if: github.event_name != 'merge_group' uses: jlumbroso/free-disk-space@main with: tool-cache: false - - - name: Checkout - if: github.event_name == 'push' || steps.check-files.outputs.any_changed == 'true' - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha || github.ref }} - persist-credentials: false - + - name: Create Deployment - if: github.event_name == 'push' || steps.check-files.outputs.any_changed == 'true' + if: github.event_name == 'push' || (steps.check-files.outputs.any_changed == 'true' && startsWith(github.event_name, 'pull_request')) uses: actions/github-script@v7 id: deployment env: PR_NUMBER: ${{ github.event.pull_request.number }} - REF: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref_name }} + REF: ${{ startsWith(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.ref_name }} with: result-encoding: string script: | @@ -99,7 +99,7 @@ jobs: GITHUB_REF_NAME: ${{ github.ref_name }} run: | case "${GITHUB_EVENT_NAME}" in - "pull_request_target") + "merge_group" | "pull_request" | "pull_request_target") echo "PATH_PREFIX=/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" >> $GITHUB_ENV ;; "push") @@ -127,7 +127,7 @@ jobs: dotnet run --project src/docs-builder -- --strict --path-prefix "${PATH_PREFIX}" - name: Build documentation - if: github.repository != 'elastic/docs-builder' && steps.deployment.outputs.result + if: github.repository != 'elastic/docs-builder' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_changed == 'true' && github.event_name == 'merge_group')) uses: elastic/docs-builder@main continue-on-error: ${{ fromJSON(inputs.continue-on-error != '' && inputs.continue-on-error || 'false') }} with: @@ -135,7 +135,7 @@ jobs: strict: ${{ fromJSON(inputs.strict != '' && inputs.strict || 'true') }} - uses: elastic/docs-builder/actions/validate-inbound-local@main - if: ${{ !cancelled() && steps.deployment.outputs.result }} + if: ${{ !cancelled() && (steps.deployment.outputs.result || (steps.check-files.outputs.any_changed == 'true' && github.event_name == 'merge_group')) }} - uses: elastic/docs-builder/.github/actions/aws-auth@main if: ${{ !cancelled() && steps.deployment.outputs.result }}