|
| 1 | +name: ✅ Check GH Repos 🎋 |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + workflow_dispatch: |
| 6 | + schedule: |
| 7 | + - cron: "30 23 * * *" #11:30 PM UTC --> 05:15 AM NPT |
| 8 | + |
| 9 | +jobs: |
| 10 | + RepoChecker: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + issues: write |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + path: main |
| 19 | + filter: "blob:none" |
| 20 | + |
| 21 | + - name: Setup Env |
| 22 | + run: | |
| 23 | + ##presets |
| 24 | + set +x ; set +e |
| 25 | + #-------------# |
| 26 | + ##CoreUtils |
| 27 | + sudo apt update -y |
| 28 | + sudo apt install bc coreutils curl dos2unix fdupes jq moreutils wget -y |
| 29 | + sudo apt-get install apt-transport-https apt-utils ca-certificates coreutils dos2unix gnupg2 jq moreutils p7zip-full rename rsync software-properties-common texinfo tmux util-linux wget -y 2>/dev/null ; sudo apt-get update -y 2>/dev/null |
| 30 | + echo "GIT_TERMINAL_PROMPT=0" >> "${GITHUB_ENV}" |
| 31 | + echo "GIT_ASKPASS=/bin/echo" >> "${GITHUB_ENV}" |
| 32 | + ##User-Agent |
| 33 | + USER_AGENT="$(curl -qfsSL 'https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Misc/User-Agents/ua_firefox_macos_latest.txt')" && export USER_AGENT="${USER_AGENT}" |
| 34 | + echo "USER_AGENT=${USER_AGENT}" >> "${GITHUB_ENV}" |
| 35 | + ##Tools |
| 36 | + #PARALLEL="1" bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh") |
| 37 | + continue-on-error: true |
| 38 | + |
| 39 | + - name: Gen Markdown (Main + Archived) |
| 40 | + run: | |
| 41 | + ##presets |
| 42 | + set +x ; set +e |
| 43 | + #-------------# |
| 44 | + pushd "$(mktemp -d)" >/dev/null 2>&1 |
| 45 | + rm -rvf "/tmp/ARCHIVED.txt" 2>/dev/null |
| 46 | + #curl -qfsSL "https://meta.pkgforge.dev/soarpkgs/data/INDEX.json" | jq -r '.[] | select(._disabled == "false") | .src_url[]' | sort -u -o "${GITHUB_WORKSPACE}/main/soarpkgs/data/URLS.txt" |
| 47 | + cat "${GITHUB_WORKSPACE}/main/soarpkgs/data/INDEX.json" | jq -r '.[] | select(._disabled == "false") | .src_url[]' | sort -u -o "${GITHUB_WORKSPACE}/main/soarpkgs/data/URLS.txt" |
| 48 | + grep -Ei "github.com" "${GITHUB_WORKSPACE}/main/soarpkgs/data/URLS.txt" | sed 's|https://github.com/\(.*\)/\(.*\)|https://api.gh.pkgforge.dev/repos/\1/\2|' | sort -u -o "./repos.txt" |
| 49 | + { |
| 50 | + readarray -t "REPOS" < "./repos.txt" |
| 51 | + echo "| User | Repo | Stars | Description | Last Updated |" |
| 52 | + echo "|------|------|-------|-------------|--------------|" |
| 53 | + for repo_url in "${REPOS[@]}"; do |
| 54 | + unset response ; response=$(curl -qsL "$repo_url") |
| 55 | + if [ -n "${response}" ]; then |
| 56 | + user=$(jq -r '.owner.login' <<< "$response") |
| 57 | + archived=$(jq -r '.archived' <<< "$response") |
| 58 | + if [[ "$archived" == "true" ]]; then |
| 59 | + echo "${repo_url}" >> "/tmp/ARCHIVED.txt" |
| 60 | + fi |
| 61 | + description=$(jq -r '.description // "No description provided."' <<< "$response" | sed 's/`//g' | sed 's/^[ \t]*//;s/[ \t]*$//' | sed ':a;N;$!ba;s/\r\n//g; s/\n//g' | sed 's/["'\'']//g' | sed 's/|//g' | sed 's/`//g') |
| 62 | + last_updated=$(jq -r '.updated_at' <<< "$response") |
| 63 | + repo=$(jq -r '.name' <<< "$response") |
| 64 | + repo_url="https://github.com/$user/$repo" |
| 65 | + stars=$(jq -r '.stargazers_count' <<< "$response") |
| 66 | + user_url="https://github.com/$user" |
| 67 | + if [[ "$user" != "null" && "$repo" != "null" ]]; then |
| 68 | + echo "| [$user]($user_url) | [$repo]($repo_url) | $stars | $description | $last_updated |" |
| 69 | + fi |
| 70 | + fi |
| 71 | + done |
| 72 | + } | tee "./GH_REPO.md" |
| 73 | + if [[ -s "./GH_REPO.md" ]] && [[ $(stat -c%s "./GH_REPO.md") -gt 100 ]]; then |
| 74 | + cp -fv "./GH_REPO.md" "${GITHUB_WORKSPACE}/main/soarpkgs/data/GH_REPO.md" |
| 75 | + fi |
| 76 | + ##Archived |
| 77 | + if [[ -s "/tmp/ARCHIVED.txt" ]] && [[ $(stat -c%s "/tmp/ARCHIVED.txt") -gt 100 ]]; then |
| 78 | + { |
| 79 | + readarray -t "REPOS" < "/tmp/ARCHIVED.txt" |
| 80 | + echo "| User | Repo | Stars | Description | Last Updated |" |
| 81 | + echo "|------|------|-------|-------------|--------------|" |
| 82 | + for repo_url in "${REPOS[@]}"; do |
| 83 | + unset response ; response=$(curl -qsL "$repo_url") |
| 84 | + if [ -n "${response}" ]; then |
| 85 | + user=$(jq -r '.owner.login' <<< "$response") |
| 86 | + user_url="https://github.com/$user" |
| 87 | + repo=$(jq -r '.name' <<< "$response") |
| 88 | + repo_url="https://github.com/$user/$repo" |
| 89 | + description=$(jq -r '.description // "No description provided."' <<< "$response" | sed 's/`//g' | sed 's/^[ \t]*//;s/[ \t]*$//' | sed ':a;N;$!ba;s/\r\n//g; s/\n//g' | sed 's/["'\'']//g' | sed 's/|//g' | sed 's/`//g') |
| 90 | + last_updated=$(jq -r '.updated_at' <<< "$response") |
| 91 | + stars=$(jq -r '.stargazers_count' <<< "$response") |
| 92 | + echo "| [$user]($user_url) | [$repo]($repo_url) | $stars | $description | $last_updated |" |
| 93 | + fi |
| 94 | + done |
| 95 | + } | tee "./ARCHIVED.md" |
| 96 | + fi |
| 97 | + if [[ -s "./ARCHIVED.md" ]] && [[ $(stat -c%s "./ARCHIVED.md") -gt 100 ]]; then |
| 98 | + cp -fv "./ARCHIVED.md" "${GITHUB_WORKSPACE}/main/soarpkgs/data/GH_REPO_ARCHIVED.md" |
| 99 | + cp -fv "${GITHUB_WORKSPACE}/main/soarpkgs/data/GH_REPO_ARCHIVED.md" "/tmp/ARCHIVED.md" |
| 100 | + fi |
| 101 | + popd "$(mktemp -d)" >/dev/null 2>&1 |
| 102 | + continue-on-error: true |
| 103 | + |
| 104 | + - name: Create Issue From File |
| 105 | + uses: peter-evans/create-issue-from-file@v5 |
| 106 | + with: |
| 107 | + title: SBUILDS (Archived Repos) |
| 108 | + content-filepath: "/tmp/ARCHIVED.md" |
| 109 | + labels: report, automated issue |
| 110 | + continue-on-error: true |
| 111 | + |
| 112 | + - name: Get DateTime & Purge files (=> 95 MB) |
| 113 | + run: | |
| 114 | + #Presets |
| 115 | + set +x ; set +e |
| 116 | + #--------------# |
| 117 | + UTC_TIME="$(TZ='UTC' date +'%Y-%m-%d (%I:%M:%S %p)')" |
| 118 | + echo "UTC_TIME=$UTC_TIME" >> $GITHUB_ENV |
| 119 | + #Purge |
| 120 | + find "${GITHUB_WORKSPACE}/main" -path "${GITHUB_WORKSPACE}/main/.git" -prune -o -type f -size +95M -exec rm -rvf "{}" + 2>/dev/null |
| 121 | + continue-on-error: true |
| 122 | + |
| 123 | + - name: Git Pull & Update Readme |
| 124 | + run: | |
| 125 | + #Presets |
| 126 | + set +x ; set +e |
| 127 | + #--------------# |
| 128 | + cd "${GITHUB_WORKSPACE}/main" && git pull origin main || git pull origin main --ff-only || git merge --no-ff -m "Merge & Sync" |
| 129 | + continue-on-error: true |
| 130 | + |
| 131 | + - uses: stefanzweifel/git-auto-commit-action@v6 |
| 132 | + with: |
| 133 | + repository: ./main |
| 134 | + commit_message: "✅ Checked GH Repos 🎋" |
| 135 | + continue-on-error: true |
| 136 | + |
| 137 | + - name: Pull & Push (2) |
| 138 | + run: | |
| 139 | + #Presets |
| 140 | + set +x ; set +e |
| 141 | + #--------------# |
| 142 | + cd "${GITHUB_WORKSPACE}/main" |
| 143 | + git pull origin main --no-edit 2>/dev/null |
| 144 | + git pull origin main --ff-only ; git merge --no-ff -m "Merge & Sync" |
| 145 | + continue-on-error: true |
| 146 | + - uses: stefanzweifel/git-auto-commit-action@v6 |
| 147 | + with: |
| 148 | + repository: ./main |
| 149 | + commit_message: "✅ Checked GH Repos 🎋" |
| 150 | + #push_options: '--force' |
| 151 | + continue-on-error: true |
0 commit comments