Update download counts #154
This file contains 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 download counts | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs once daily | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update-remote-gist: | |
runs-on: ubuntu-latest | |
env: | |
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | |
REPO_FULL: ${{ github.repository }} | |
steps: | |
- name: Restore cached binary | |
id: cache | |
continue-on-error: true | |
uses: actions/cache/restore@v4 | |
with: | |
path: ./nexus-mods.gz | |
key: ${{ vars.CACHED_BIN }} | |
- name: Decompress cached binary | |
if: steps.cache.outputs.cache-hit | |
run: | | |
gunzip -f ./nexus-mods.gz | |
chmod +x ./nexus-mods | |
- name: Check for update | |
id: check_ver | |
if: steps.cache.outputs.cache-hit | |
continue-on-error: true | |
run: | | |
set +e | |
./nexus-mods --remote version | |
echo "exit_code=$?" >> $GITHUB_OUTPUT | |
- name: Download latest binary | |
id: download_latest | |
if: ${{ !steps.cache.outputs.cache-hit || steps.check_ver.outputs.exit_code != '0' }} | |
continue-on-error: true | |
run: | | |
wget "https://github.com/WardLordRuby/nexus_badges/releases/latest/download/nexus_badges_linux_amd64.gz" -O ./nexus-mods.gz | |
echo "cache_key_new=${{ runner.os }}-binary-nexus-badges-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_OUTPUT | |
- name: Cache latest binary | |
id: cache_latest | |
if: steps.download_latest.outcome == 'success' | |
uses: actions/cache/save@v4 | |
with: | |
path: ./nexus-mods.gz | |
key: ${{ steps.download_latest.outputs.cache_key_new }} | |
- name: Decompress latest binary | |
if: steps.download_latest.outcome == 'success' | |
run: | | |
gunzip -f ./nexus-mods.gz | |
chmod +x ./nexus-mods | |
- name: Set cache key | |
if: ${{ steps.cache_latest.outcome == 'success' && !steps.cache.outputs.cache-hit }} | |
continue-on-error: true | |
run: ./nexus-mods --remote update-cache-key --new ${{ steps.download_latest.outputs.cache_key_new }} | |
- name: Remove old cache & update cache key | |
if: ${{ steps.cache_latest.outcome == 'success' && steps.cache.outputs.cache-hit }} | |
continue-on-error: true | |
run: ./nexus-mods --remote update-cache-key --old ${{ vars.CACHED_BIN }} --new ${{ steps.download_latest.outputs.cache_key_new }} | |
- name: Run binary | |
env: | |
NEXUS_KEY: ${{ secrets.NEXUS_KEY }} | |
GIST_ID: ${{ vars.GIST_ID }} | |
TRACKED_MODS: ${{ vars.TRACKED_MODS }} | |
run: ./nexus-mods --remote |