From fc3a91e416bec8c0afe8ac0dcb411e74a5feba17 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:23:51 +0100 Subject: [PATCH] docs: add backport labels --- .github/workflows/clean-up-unused-images.yaml | 17 +++++++++++++---- msg | 4 ---- pr_body | 9 --------- scripts/find-unused-images.sh | 9 +++++---- 4 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 msg delete mode 100644 pr_body diff --git a/.github/workflows/clean-up-unused-images.yaml b/.github/workflows/clean-up-unused-images.yaml index 79604e3723..962d73cacd 100644 --- a/.github/workflows/clean-up-unused-images.yaml +++ b/.github/workflows/clean-up-unused-images.yaml @@ -63,9 +63,6 @@ jobs: rm static/assets/docs/images/$img done - # Clean up results file. - rm unused_images.json - # Commit and push branch git add . git commit -m "docs: clean up unused images" @@ -77,8 +74,20 @@ jobs: This PR removes images identified as unused across all our branches.\n The images are identified using `scripts/find-unused-images.sh` script.\n Please review this PR carefully before merging it.\n' > pr_body + + backport_labels="auto-backport" + for branch in $(cat evaluated_branches.json); do + if [[ $branch =~ version-[0-9]+(-[0-9]+)*$ ]]; then + backport_labels+=",backport-$branch" + fi + done + + export pr_body=$(cat pr_body) ; gh pr create --base master --title "docs: clean up librarium unused images " --body "$pr_body" --label "$backport_labels" + + # Clean up results file. + rm unused_images.json + rm evaluated_branches.json - export pr_body=$(cat pr_body) ; gh pr create --base master --title "docs: clean up librarium unused images " --body "$pr_body" env: GH_TOKEN: ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }} diff --git a/msg b/msg deleted file mode 100644 index be4bc32165..0000000000 --- a/msg +++ /dev/null @@ -1,4 +0,0 @@ -line1 -line2 -line3 - diff --git a/pr_body b/pr_body deleted file mode 100644 index 12c1afe622..0000000000 --- a/pr_body +++ /dev/null @@ -1,9 +0,0 @@ - - ## Describe the Change - - This PR removes images identified as unused across all our branches. - - The images are identified using `scripts/find-unused-images.sh` script. - - Please review this PR carefully before merging it. - diff --git a/scripts/find-unused-images.sh b/scripts/find-unused-images.sh index 7f843843f0..0adc4a4d62 100755 --- a/scripts/find-unused-images.sh +++ b/scripts/find-unused-images.sh @@ -5,9 +5,9 @@ set -e # Create a list of all the images we have and save it to a json. # Trim the path static/assets/docs/images. -find static/assets/docs/images -type f ! -name ".DS_STORE" ! -name ".DS_Store" | sed 's|static/assets/docs/images||g' > all_images.json +find static/assets/docs/images -type f \( -name "*.gif" -o -name "*.webp" \) ! -name ".DS_STORE" ! -name ".DS_Store" | sed 's|static/assets/docs/images||g' > all_images.json image_count=$(wc -l < all_images.json) -echo "Detected $image_count webp assets in static/assets/docs/images..." +echo "Detected $image_count .webp and .gif assets in static/assets/docs/images..." # Fetch all branches git fetch --all @@ -23,12 +23,13 @@ for version_branch in $version_branches; do done echo "Evaluating the following branches for image usage: { $branches }" +echo "$branches" > evaluated_branches.json for current_branch in $branches; do git checkout $current_branch - find docs -type f -name "*.md" -exec grep -Hn "\.webp" {} + > docs_used_images.json - find _partials -type f -name "*.mdx" -exec grep -Hn "\.webp" {} + > partials_used_images.json + find docs -type f -name "*.md" -exec grep -Hn -E "\.webp|\.gif" {} \; > docs_used_images.json + find _partials -type f -name "*.mdx" -exec grep -Hn -E "\.webp|\.gif" {} \; > partials_used_images.json cat docs_used_images.json partials_used_images.json > used_images.json line_number=1