Skip to content
Open
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
131 changes: 0 additions & 131 deletions .github/workflows/bzlmod-lock-check.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/copyright.yml

This file was deleted.

69 changes: 68 additions & 1 deletion .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,79 @@ jobs:
name: Cleanup old documentation
needs: detect-repo-capabilities
if: needs.detect-repo-capabilities.outputs.should_run_docs_cleanup == 'true'
uses: ./.github/workflows/docs-cleanup.yml
runs-on: ${{ inputs.runner-labels && fromJSON(inputs.runner-labels) || vars.runner_labels_ghub_standard_x64 && fromJSON(vars.runner_labels_ghub_standard_x64) || vars.REPO_RUNNER_LABELS && fromJSON(vars.REPO_RUNNER_LABELS) || 'ubuntu-latest' }}
permissions:
contents: write
pull-requests: read
pages: write
id-token: write
steps:
- name: Checkout repository root for deploy context
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: gh-pages
fetch-depth: 0

- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: gh-pages
fetch-depth: 0
path: gh-pages-cleanup

- name: Install GitHub CLI
run: sudo apt-get update && sudo apt-get install -y gh jq

- name: Cleanup old documentation
working-directory: gh-pages-cleanup
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail

gh auth status

ACTIVE_BRANCHES=$(gh api --paginate repos/${{ github.repository }}/branches --jq '.[].name')
OPEN_PRS=$(gh api --paginate repos/${{ github.repository }}/pulls --jq '.[] | "pr-\(.number)"')
TAGS=$(gh api --paginate repos/${{ github.repository }}/tags --jq '.[].name')
VALID_ENTRIES=$(echo -e "$ACTIVE_BRANCHES\n$OPEN_PRS\n$TAGS")
CURRENT_FOLDERS=$(find . -maxdepth 1 -type d -not -name '.' -not -path './.*' -exec basename {} \;)

if [[ -f versions.json ]]; then
jq '.' versions.json > versions_tmp.json
else
echo "[]" > versions_tmp.json
fi

for FOLDER in $CURRENT_FOLDERS; do
if ! echo "$VALID_ENTRIES" | grep -Fxq "$FOLDER"; then
echo "Removing $FOLDER"
rm -rf "$FOLDER"
jq --arg ver "$FOLDER" 'map(select(.version != $ver))' versions_tmp.json > tmp.json && mv tmp.json versions_tmp.json
fi
done

jq '[.[] | select((.version | IN($folders[])))]' --argjson folders "$(ls -1 | jq -R -s -c 'split("\n")[:-1]')" versions_tmp.json > versions_tmp_clean.json

jq --arg repo "${{ github.repository }}" \
--arg owner "${{ github.repository_owner }}" \
'[.[] | select(.version != "main")]
| sort_by(.version)
| [{"version":"main",
"url":("https://" + $owner + ".github.io/" + ($repo | split("/")[1]) + "/main/")}]
+ .' \
versions_tmp_clean.json > versions.json

rm versions_tmp.json versions_tmp_clean.json

- name: Commit and Push Changes
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: gh-pages-cleanup
commit-message: "Daily cleanup of outdated documentation"

cache-cleanup:
name: Cleanup old caches
Expand Down
118 changes: 0 additions & 118 deletions .github/workflows/docs-cleanup.yml

This file was deleted.

Loading
Loading