Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

83 lines
3.3 KiB
YAML

# Clean up documentation preview versions from Read the Docs
# ---------------------------------------------------------
# This workflow triggers when a PR is closed (merged or abandoned).
# It checks if a docs preview was created by parsing PR comments posted
# by the bot, then deactivates the corresponding version on Read the Docs.
name: Docs Preview Cleanup
on:
pull_request:
types: [closed]
permissions:
contents: read
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout docs-config only
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: |
.github/docs-config.json
sparse-checkout-cone-mode: false
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Get project slug from preview comment
id: rtd
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
# Extract project identifier from the bot's comment.
# The JSON output for a valid commit will have "assistant-librarian[bot]"
# for key `user.login` and contain "rocm.docs.amd.com/projects/" for key `body`
# and we need to parse "rocm.docs.amd.com/projects/project_slug/xyz..." to "project_slug"
comment=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '[.[] | select(.user.login == "systems-assistant[bot]" and (.body | contains("rocm.docs.amd.com/projects/")))] | last | .body')
if [ -z "$comment" ] || [ "$comment" = "null" ]; then
echo "No preview comment found, skipping cleanup."
exit 0
fi
# Extract the string immediately following "projects/" (up to the next "/") from $comment
project_alias=$(echo "$comment" | grep --only-matching --perl-regexp 'projects/\K[^/]+')
# Load the map and look up the rtd_slug by rtd_alias
project_slug=$(jq -r --arg alias "$project_alias" \
'.projects[] | select(.rtd_alias == $alias) | .rtd_slug' \
.github/docs-config.json)
echo "project_slug=$project_slug" >> $GITHUB_OUTPUT
- name: Deactivate RTD preview version
if: steps.rtd.outputs.project_slug
env:
RTD_TOKEN: ${{ secrets.RTD_TOKEN }}
run: |
branch_name="${{ github.head_ref }}"
# Generate slug like 'user-me-my_test_branch' from 'user/me/my_test_branch'
version_slug="${branch_name//\//-}"
response=$(curl \
--connect-timeout 180 \
--silent \
--output /dev/null \
--write-out "%{http_code}" \
--request PATCH \
--header "Authorization: Token $RTD_TOKEN" \
--header "Content-Type: application/json" \
--data '{"active": false}' \
"https://app.readthedocs.com/api/v3/projects/${{ steps.rtd.outputs.project_slug }}/versions/${version_slug}/")
echo "RTD PATCH responded with HTTP $response"