|
| 1 | +name: 🐧🧹 HealthChecks 🖳🗑️ |
| 2 | +#MAX_RUNTIME: 02 Minutes */10 * * * * |
| 3 | + |
| 4 | +on: |
| 5 | + #push: |
| 6 | + workflow_dispatch: |
| 7 | + schedule: |
| 8 | + - cron: "45 02 * * *" # 02:45 AM UTC --> 08:30 AM Morning NPT |
| 9 | +#------------------------------------------------------------------------------------# |
| 10 | +jobs: |
| 11 | + check: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + path: main |
| 22 | + filter: "blob:none" #https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ |
| 23 | + |
| 24 | + - name: Setup ENV |
| 25 | + run: | |
| 26 | + #presets |
| 27 | + set +x ; set +e |
| 28 | + #-------------# |
| 29 | + #tmp |
| 30 | + SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="${SYSTMP}" |
| 31 | + echo "SYSTMP=${SYSTMP}" >> "${GITHUB_ENV}" |
| 32 | + ##User-Agent |
| 33 | + USER_AGENT="$(curl -qfsSL 'https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Misc/User-Agents/ua_chrome_macos_latest.txt')" && export USER_AGENT="${USER_AGENT}" |
| 34 | + echo "USER_AGENT=${USER_AGENT}" >> "${GITHUB_ENV}" |
| 35 | + continue-on-error: true |
| 36 | + |
| 37 | + - name: Install Addons |
| 38 | + run: | |
| 39 | + #Presets |
| 40 | + set +x ; set +e |
| 41 | + #--------------# |
| 42 | + #action-lint |
| 43 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/actionlint" -o "/usr/local/bin/actionlint" && sudo chmod +xwr "/usr/local/bin/actionlint" |
| 44 | + #delta |
| 45 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/delta" -o "/usr/local/bin/delta" && sudo chmod +xwr "/usr/local/bin/delta" |
| 46 | + #dust |
| 47 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/dust" -o "/usr/local/bin/dust" && sudo chmod +xwr "/usr/local/bin/dust" |
| 48 | + #eget |
| 49 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/eget" -o "/usr/local/bin/eget" && sudo chmod +xwr "/usr/local/bin/eget" |
| 50 | + #git-sizer |
| 51 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/git-sizer" -o "/usr/local/bin/git-sizer" && sudo chmod +xwr "/usr/local/bin/git-sizer" |
| 52 | + #rclone |
| 53 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/rclone" -o "/usr/local/bin/rclone" && sudo chmod +xwr "/usr/local/bin/rclone" |
| 54 | + #validtoml |
| 55 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/validtoml" -o "/usr/local/bin/validtoml" && sudo chmod +xwr "/usr/local/bin/validtoml" |
| 56 | + #Yq |
| 57 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/yq" -o "/usr/local/bin/yq" && sudo chmod +xwr "/usr/local/bin/yq" |
| 58 | + #Yj |
| 59 | + sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/yj" -o "/usr/local/bin/yj" && sudo chmod +xwr "/usr/local/bin/yj" |
| 60 | + continue-on-error: true |
| 61 | + |
| 62 | + - name: Install Addons |
| 63 | + run: | |
| 64 | + #presets |
| 65 | + set +x ; set +e |
| 66 | + #-------------# |
| 67 | + bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh") |
| 68 | + continue-on-error: true |
| 69 | + |
| 70 | + - name: Dos2Unix Everything |
| 71 | + run: | |
| 72 | + #Presets |
| 73 | + set +x ; set +e |
| 74 | + #--------------# |
| 75 | + cd "${GITHUB_WORKSPACE}/main" |
| 76 | + find . -type f ! -path "./.git/*" -exec dos2unix {} \; 2>/dev/null |
| 77 | + continue-on-error: true |
| 78 | + |
| 79 | + - name: ActionLint |
| 80 | + run: | |
| 81 | + #Presets |
| 82 | + set +x ; set +e |
| 83 | + #--------------# |
| 84 | + cd "${GITHUB_WORKSPACE}/main" |
| 85 | + find ".github/workflows" -type f -name "*ml" -exec actionlint {} \; |
| 86 | + continue-on-error: true |
| 87 | + |
| 88 | + - name: Generate Repo Metadata (git-sizer) |
| 89 | + run: | |
| 90 | + #Presets |
| 91 | + set +x ; set +e |
| 92 | + #--------------# |
| 93 | + cd "${GITHUB_WORKSPACE}/main" |
| 94 | + #Dust sizes |
| 95 | + echo '```mathematica' > "${GITHUB_WORKSPACE}/main/.github/SIZE.md" |
| 96 | + dust -b -c -i -r -n 99999999 "${GITHUB_WORKSPACE}/main" | tee -a "${GITHUB_WORKSPACE}/main/.github/SIZE.md" |
| 97 | + dust -b -c -i -r -n 99999999 "${GITHUB_WORKSPACE}/main" | tee "${GITHUB_WORKSPACE}/main/.github/SIZE.txt" |
| 98 | + echo '```' >> "${GITHUB_WORKSPACE}/main/.github/SIZE.md" |
| 99 | + continue-on-error: true |
| 100 | + |
| 101 | + - name: Ensure Healthy Commit Nums (RESET ON >= 1000) |
| 102 | + run: | |
| 103 | + #Presets |
| 104 | + set +x ; set +e |
| 105 | + #--------------# |
| 106 | + pushd "$(mktemp -d)" > /dev/null 2>&1 && git clone --filter="blob:none" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" |
| 107 | + cd "$(find . -maxdepth 1 -type d -exec basename {} \; | grep -Ev '^\.$' | xargs -I {} realpath {})" |
| 108 | + CLONED_DIR="$(realpath .)" && export CLONED_DIR="$CLONED_DIR" |
| 109 | + COMMIT_NUMS="$(git rev-list --count HEAD)" && export COMMIT_NUMS="${COMMIT_NUMS}" |
| 110 | + popd > /dev/null 2>&1 ; rm -rf "$CLONED_DIR" 2>/dev/null |
| 111 | + cd "${GITHUB_WORKSPACE}/main" |
| 112 | + if [ "${COMMIT_NUMS}" -gt 1000 ]; then |
| 113 | + echo -e "\n[+] Total number of commits exceeds 1000. (${COMMIT_NUMS})\n" |
| 114 | + cd "${GITHUB_WORKSPACE}/main" |
| 115 | + git config "user.name" "Azathothas" |
| 116 | + git config "user.email" "[email protected]" |
| 117 | + git checkout --orphan temp |
| 118 | + git add --all --verbose && git commit -m "Purge (Re:Init)" |
| 119 | + git branch -D "main" |
| 120 | + git branch -m "main" |
| 121 | + git push --set-upstream origin main --force |
| 122 | + echo "RESET_HISTORY=YES" >> "${GITHUB_ENV}" |
| 123 | + else |
| 124 | + echo -e "\n[+] Total number of commits looks healthy. (${COMMIT_NUMS})\n" |
| 125 | + echo "RESET_HISTORY=NO" >> "${GITHUB_ENV}" |
| 126 | + fi |
| 127 | + pushd "${GITHUB_WORKSPACE}/main" >/dev/null 2>&1 && git pull origin main && popd >/dev/null 2>&1 |
| 128 | + continue-on-error: true |
| 129 | + |
| 130 | + - name: Get DateTime |
| 131 | + run: | |
| 132 | + #Date Time |
| 133 | + NEPALI_TIME="$(TZ='Asia/Kathmandu' date +'%Y-%m-%d (%I:%M:%S %p)')" |
| 134 | + echo "NEPALI_TIME=${NEPALI_TIME}" >> "${GITHUB_ENV}" |
| 135 | + continue-on-error: true |
| 136 | + |
| 137 | + - name: Git Pull |
| 138 | + run: | |
| 139 | + cd "${GITHUB_WORKSPACE}/main" && git pull origin main |
| 140 | + continue-on-error: true |
| 141 | + |
| 142 | + - uses: stefanzweifel/git-auto-commit-action@v5 |
| 143 | + with: |
| 144 | + repository: ./main |
| 145 | + commit_user_name: Azathothas # defaults to "github-actions[bot]" |
| 146 | + commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com" |
| 147 | + commit_message: "✅ 🐧🧹 🖳🗑️" |
| 148 | + #push_options: '--force' |
| 149 | + continue-on-error: true |
0 commit comments