diff --git a/.gitea/workflows/compressimages.yml b/.gitea/workflows/compressimages.yml index 8223dce..55812ef 100644 --- a/.gitea/workflows/compressimages.yml +++ b/.gitea/workflows/compressimages.yml @@ -27,6 +27,7 @@ jobs: runs-on: ubuntu-latest steps: + # 🔀 Decide branch (PR vs manual) - name: Determine Branch id: branch run: | @@ -36,23 +37,41 @@ jobs: echo "branch=${{ inputs.target_branch }}" >> $GITHUB_OUTPUT fi + # 📥 Checkout correct branch - name: Checkout Repository uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ steps.branch.outputs.branch }} - # 🚀 FAST MIRROR (India) + # 🚀 FIX: Ubuntu 24 mirror replacement (covers .list + .sources) - name: Use faster apt mirror run: | - sudo sed -i 's|http://archive.ubuntu.com/ubuntu|http://in.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list - sudo sed -i 's|http://security.ubuntu.com/ubuntu|http://in.archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list + echo "🔧 Replacing apt mirrors..." + sudo find /etc/apt -type f -name "*.list" \ + -exec sed -i 's|http://archive.ubuntu.com|http://in.archive.ubuntu.com|g' {} + + sudo find /etc/apt -type f -name "*.list" \ + -exec sed -i 's|http://security.ubuntu.com|http://in.archive.ubuntu.com|g' {} + + + sudo find /etc/apt -type f -name "*.sources" \ + -exec sed -i 's|http://archive.ubuntu.com|http://in.archive.ubuntu.com|g' {} + + sudo find /etc/apt -type f -name "*.sources" \ + -exec sed -i 's|http://security.ubuntu.com|http://in.archive.ubuntu.com|g' {} + + + # 🔍 Debug (optional but useful) + - name: Verify apt sources + run: | + echo "🔍 Current apt sources:" + grep -r "ubuntu.com" /etc/apt || true + + # 📦 Install tools - name: Install Image Tools run: | sudo apt-get update sudo apt-get install -y imagemagick jpegoptim pngquant + # 🖼 Resize images - name: Resize Oversized Images run: | find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \ @@ -60,6 +79,7 @@ jobs: -not -path "*/node_modules/*" \ -exec mogrify -resize 1920x1920\> {} \; + # 📉 Optimize JPEG - name: Optimize JPEG run: | find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \ @@ -67,6 +87,7 @@ jobs: -not -path "*/node_modules/*" \ -exec jpegoptim --strip-all --max=85 {} \; + # 📉 Optimize PNG - name: Optimize PNG run: | find . -type f -iname "*.png" \ @@ -74,6 +95,7 @@ jobs: -not -path "*/node_modules/*" \ -exec pngquant --force --ext .png --quality=75-90 {} \; + # 💾 Commit if changes exist - name: Commit changes run: | git config --global user.name "CI Bot" @@ -86,6 +108,7 @@ jobs: echo "No changes to commit" fi + # 🚀 Push back to branch - name: Push changes run: | git push origin HEAD:${{ steps.branch.outputs.branch }} \ No newline at end of file