|
| 1 | +name: "DiligentGraphics: Clean Disk Space" |
| 2 | +description: "Remove unneeded packages and tools to free disk space" |
| 3 | + |
| 4 | +inputs: |
| 5 | + preserve-android-ndk: |
| 6 | + description: Android NDK version to preserve |
| 7 | + required: false |
| 8 | + default: "27.0.12077973" |
| 9 | + |
| 10 | +runs: |
| 11 | + using: "composite" # must be set to "composite" |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Available disk space |
| 15 | + shell: bash |
| 16 | + run: | |
| 17 | + # Available disk space |
| 18 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 19 | +
|
| 20 | + - name: Remove .NET |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + # Remove .NET |
| 24 | + sudo rm -rf /usr/share/dotnet || echo "::warning::Failed to remove .NET" |
| 25 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 26 | +
|
| 27 | + - name: Remove Swift |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + # Remove Swift |
| 31 | + sudo rm -rf /usr/share/swift || echo "::warning::Failed to remove Swift" |
| 32 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 33 | +
|
| 34 | + - name: Remove CodeQL Action Bundles |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + # Remove CodeQL Action Bundles |
| 38 | + sudo rm -rf /opt/hostedtoolcache/CodeQL || echo "::warning::Failed to remove CodeQL Action Bundles" |
| 39 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 40 | +
|
| 41 | + - name: Remove image tool cache |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + # Remove image tool cache |
| 45 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" || echo "::warning::Failed to remove image tool cache" |
| 46 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 47 | +
|
| 48 | + - name: Remove unused Android NDKs |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + # Remove unused Android NDKs |
| 52 | + ANDROID_NDK_DIR=/usr/local/lib/android/sdk/ndk |
| 53 | + echo "Current NDKs:" |
| 54 | + ls $ANDROID_NDK_DIR |
| 55 | + for dir in $ANDROID_NDK_DIR/* ; do |
| 56 | + if [ "${dir%/}" != "$ANDROID_NDK_DIR/${{ inputs.preserve-android-ndk }}" ]; then |
| 57 | + rm -rf "$dir" |
| 58 | + fi |
| 59 | + done |
| 60 | + echo "Remaining NDKs:" |
| 61 | + ls $ANDROID_NDK_DIR |
| 62 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 63 | +
|
| 64 | + - name: Remove cached Docker images |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + # Remove cached Docker images |
| 68 | + sudo docker image prune --all --force || echo "::warning::Failed to remove Docker images" |
| 69 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 70 | +
|
| 71 | + - name: Remove ASP.NET Core |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + # Remove ASP.NET Core |
| 75 | + sudo apt-get remove -y '^aspnetcore-.*' --fix-missing || echo "::warning::Failed to remove ASP.NET Core" |
| 76 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 77 | +
|
| 78 | + - name: Remove Azure CLI |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + # Remove Azure CLI |
| 82 | + sudo apt-get remove -y azure-cli --fix-missing || echo "::warning::Failed to remove Azure CLI" |
| 83 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 84 | +
|
| 85 | + - name: Remove Chrome and Firefox |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + # Remove Chrome and Firefox |
| 89 | + sudo apt-get remove -y google-chrome-stable firefox --fix-missing || echo "::warning::Failed to remove Chrome and Firefox" |
| 90 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 91 | +
|
| 92 | + - name: APT Cleanup |
| 93 | + shell: bash |
| 94 | + run: | |
| 95 | + # APT Cleanup |
| 96 | + sudo apt-get autoremove -y || echo "::warning::Failed to remove unneeded packages" |
| 97 | + sudo apt-get clean || echo "::warning::Failed to clean up" |
| 98 | + echo -e "Free disk space: $(df -BM / | awk 'NR==2 {print $4}' | sed 's/M//') MB\n " |
| 99 | +
|
| 100 | + - name: Disk space after cleanup |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + # Disk space after cleanup |
| 104 | + df -h |
0 commit comments