-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.56 KB
/
automation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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