Update MoeCounter and Package Counts #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update MoeCounter and Package Counts | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
jobs: | |
update-counter: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dbin | |
run: | | |
# Disable config file reads | |
export DBIN_NOCONFIG="1" | |
echo "DBIN_NOCONFIG=$DBIN_NOCONFIG" >> $GITHUB_ENV | |
# Set cache dir to /tmp | |
export DBIN_CACHE_DIR="/tmp/dbin" | |
echo "DBIN_CACHE_DIR=$DBIN_CACHE_DIR" >> $GITHUB_ENV | |
wget -qO- "https://raw.githubusercontent.com/xplshn/dbin/master/stubdl" | sh -s -- --install "/usr/local/bin/dbin" | |
- name: Get package counts for repositories | |
id: get-package-counts | |
run: | | |
# Set DBIN_REPO_URLS for each repository and get counts | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/amd64_linux.lite.cbor.zst" | |
DEFAULTS_COUNT=$(dbin list | wc -l) | |
echo "DEFAULTS_COUNT=$DEFAULTS_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/bincache_amd64_linux.lite.cbor.zst" | |
BINCACHE_COUNT=$(dbin list | wc -l) | |
echo "BINCACHE_COUNT=$BINCACHE_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/pkgcache_amd64_linux.lite.cbor.zst" | |
PKGCACHE_COUNT=$(dbin list | wc -l) | |
echo "PKGCACHE_COUNT=$PKGCACHE_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/AppBundleHUB_amd64_linux.lite.cbor.zst" | |
APPBUNDLEHUB_COUNT=$(dbin list | wc -l) | |
echo "APPBUNDLEHUB_COUNT=$APPBUNDLEHUB_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/AM_amd64_linux.lite.cbor.zst" | |
AM_COUNT=$(dbin list | wc -l) | |
echo "AM_COUNT=$AM_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/pkgforge-go_amd64_linux.lite.cbor.zst" | |
GO_COUNT=$(dbin list | wc -l) | |
echo "GO_COUNT=$GO_COUNT" >> $GITHUB_ENV | |
export DBIN_REPO_URLS="https://d.xplshn.com.ar/misc/cmd/1.6/pkgforge-cargo_amd64_linux.lite.cbor.zst" | |
CARGO_COUNT=$(dbin list | wc -l) | |
echo "CARGO_COUNT=$CARGO_COUNT" >> $GITHUB_ENV | |
- name: Update README with package counts | |
run: | | |
# Replace entire line containing each PKGCOUNT comment with new count + comment | |
sed -i "s|.*<!-- BINCACHE_COUNT -->.*| - Bincache: ${{ env.BINCACHE_COUNT }} <!-- BINCACHE_COUNT -->|" README.md | |
sed -i "s|.*<!-- PKGCACHE_COUNT -->.*| - Pkgcache: ${{ env.PKGCACHE_COUNT }} <!-- PKGCACHE_COUNT -->|" README.md | |
sed -i "s|.*<!-- APPBUNDLEHUB_COUNT -->.*| - ${{ env.APPBUNDLEHUB_COUNT }} <!-- APPBUNDLEHUB_COUNT -->|" README.md | |
sed -i "s|.*<!-- AM_COUNT -->.*| - ${{ env.AM_COUNT }} <!-- AM_COUNT -->|" README.md | |
sed -i "s|.*<!-- GO_COUNT -->.*| - ${{ env.GO_COUNT }} <!-- GO_COUNT -->|" README.md | |
sed -i "s|.*<!-- CARGO_COUNT -->.*| - ${{ env.CARGO_COUNT }} <!-- CARGO_COUNT -->|" README.md | |
- name: Download MoeCounter image | |
run: | | |
wget -O ./misc/assets/counter.svg \ | |
"https://api.sefinek.net/api/v2/moecounter?number=${{ env.DEFAULTS_COUNT }}&length=5&theme=default&pixelated=true" | |
- name: Commit and push updated counter image and README | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add ./misc/assets/counter.svg README.md | |
git commit -m "[WEEKLY] Update MoeCounter image and package counts" | |
git push |