process: inspection concept #744
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ******************************************************************************* | |
# Copyright (c) 2025 Contributors to the Eclipse Foundation | |
# | |
# See the NOTICE file(s) distributed with this work for additional | |
# information regarding copyright ownership. | |
# | |
# This program and the accompanying materials are made available under the | |
# terms of the Apache License Version 2.0 which is available at | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# ******************************************************************************* | |
name: Documentation | |
on: | |
pull_request_target: | |
types: [opened, reopened, synchronize] # Handles forked PRs | |
push: | |
merge_group: | |
types: [checks_requested] | |
jobs: | |
docs-build: | |
name: Build documentation | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
# ------------------------------------------------------------------------------ | |
# Checkout the correct branch safely in all scenarios (PRs, forks, merges) | |
# ------------------------------------------------------------------------------ | |
# | Condition | Event Type | Checked Out Branch | | |
# |----------------------------------------|--------------------|-----------------------| | |
# | github.head_ref | pull_request_target | PR branch (source branch) | | |
# | github.event.pull_request.head.ref | pull_request | PR branch (source branch) | | |
# | github.ref | push, merge_group | The branch being pushed/merged | | |
# ------------------------------------------------------------------------------ | |
# ------------------------------------------------------------------------------ | |
# Checkout the correct repository safely in all scenarios (PRs, forks, merges) | |
# ------------------------------------------------------------------------------ | |
# | Condition | Event Type | Checked Out Repository | | |
# |------------------------------------------------|--------------------|----------------------------------| | |
# | github.event.pull_request.head.repo.full_name | pull_request | Forked repository (if PR is from a fork) | | |
# | github.repository | push, merge_group | Default repository (same repo PRs, merges, pushes) | | |
- name: Checkout repository (Handle all events) | |
uses: actions/[email protected] | |
with: | |
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
- name: Setup Bazel | |
uses: bazel-contrib/[email protected] | |
- name: Build documentation | |
run: | | |
bazel build //docs:github-pages && cp bazel-bin/docs/github-pages.tar . | |
# ------------------------------------------------------------------------------ | |
# Generate a unique artifact name to ensure proper tracking in all scenarios | |
# ------------------------------------------------------------------------------ | |
# | Condition | Event Type | Artifact Name Value | | |
# |-----------------------------------------------|------------------------|----------------------------------------------| | |
# | github.event.pull_request.head.sha | pull_request | PR commit SHA (ensures uniqueness per PR) | | |
# | github.event.pull_request.head.sha | pull_request_target | PR commit SHA (ensures uniqueness per PR) | | |
# | github.sha | push, merge_group | Current commit SHA (used for main branch) | | |
# ------------------------------------------------------------------------------ | |
- name: Upload artifact for job analysis | |
uses: actions/[email protected] | |
with: | |
name: github-pages-${{ github.event.pull_request.head.sha || github.sha }} | |
path: github-pages.tar | |
retention-days: 1 | |
if-no-files-found: error | |
docs-deploy: | |
name: Deploy documentation to GitHub Pages | |
permissions: | |
pages: write | |
id-token: write | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
needs: docs-build | |
steps: | |
# ------------------------------------------------------------------------------ | |
# Always checks out the BASE repository since pull_request_target is used. | |
# This ensures that the workflow runs with trusted code from the base repo, | |
# even when triggered by a pull request from a fork. | |
# ------------------------------------------------------------------------------ | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Download documentation artifact | |
uses: actions/[email protected] | |
# ------------------------------------------------------------------------------ | |
# Generate a unique artifact name to ensure proper tracking in all scenarios | |
# ------------------------------------------------------------------------------ | |
# | Condition | Event Type | Artifact Name Value | | |
# |-----------------------------------------------|------------------------|----------------------------------------------| | |
# | github.event.pull_request.head.sha | pull_request | PR commit SHA (ensures uniqueness per PR) | | |
# | github.event.pull_request.head.sha | pull_request_target | PR commit SHA (ensures uniqueness per PR) | | |
# | github.sha | push, merge_group | Current commit SHA (used for main branch) | | |
# ------------------------------------------------------------------------------ | |
with: | |
name: github-pages-${{ github.event.pull_request.head.sha || github.sha }} | |
- name: Untar documentation artifact | |
run: mkdir -p extracted_docs && tar -xf github-pages.tar -C extracted_docs | |
- name: Deploy 🚀 | |
id: pages-deployment | |
uses: ./.github/actions/deploy-versioned-pages | |
with: | |
source_folder: extracted_docs |