Skip to content

Commit

Permalink
docs: add backport labels
Browse files Browse the repository at this point in the history
  • Loading branch information
addetz committed Oct 23, 2024
1 parent d2a663a commit fc3a91e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/clean-up-unused-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}

Expand Down
4 changes: 0 additions & 4 deletions msg

This file was deleted.

9 changes: 0 additions & 9 deletions pr_body

This file was deleted.

9 changes: 5 additions & 4 deletions scripts/find-unused-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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
Expand Down

0 comments on commit fc3a91e

Please sign in to comment.