|
1 | | -name: Update cache |
| 1 | +name: Nightly cache refresh |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - foo |
7 | | - # - develop |
8 | | - # schedule: |
9 | | - # - cron: '15 0 * * *' |
| 4 | + schedule: |
| 5 | + - cron: '0 1 * * *' |
| 6 | + workflow_dispatch: |
10 | 7 |
|
11 | 8 | jobs: |
12 | | - resources: |
13 | | - name: Update cache |
| 9 | + refresh-cache: |
14 | 10 | runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - name: Check out code into the Go module directory |
17 | | - uses: actions/checkout@v2 |
18 | | - |
19 | | - - name: Set up NodeJS |
20 | | - uses: actions/setup-node@v1 |
| 11 | + permissions: |
| 12 | + contents: write |
21 | 13 |
|
22 | | - - name: Set up Go 1.22 |
23 | | - uses: actions/setup-go@v2 |
| 14 | + steps: |
| 15 | + - name: Check out repository |
| 16 | + uses: actions/checkout@v4 |
24 | 17 | with: |
25 | | - go-version: 1.22 |
26 | | - id: go |
| 18 | + fetch-depth: 0 |
27 | 19 |
|
28 | | - - name: Build binary |
29 | | - run: make all |
30 | | - |
31 | | - - name: Create cache |
32 | | - run: export GITHUB_TOKEN=${{ secrets.GO_RELEASER_GITHUB_TOKEN }} && ./bin/binenv update -f -v -c2 |
| 20 | + - name: Set up Go |
| 21 | + uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version: '1.25' |
33 | 24 |
|
34 | | - - name: Format caches |
35 | | - run: jq '.' distributions/cache.json > dist.json && jq '.' ~/.cache/binenv/cache.json > new.json |
| 25 | + - name: Build cache |
| 26 | + env: |
| 27 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + run: scripts/buildcache.sh |
36 | 29 |
|
37 | | - - name: Compare caches |
38 | | - id: compare |
| 30 | + - name: Commit cache artifacts |
| 31 | + env: |
| 32 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
39 | 33 | run: | |
40 | | - echo "DIFF=$(diff dist.json new.json > /dev/null 2>&1; echo $?)" >> $GITHUB_ENV |
| 34 | + if git diff --quiet -- distributions/cache.json; then |
| 35 | + echo "Cache already up to date" |
| 36 | + exit 0 |
| 37 | + fi |
41 | 38 |
|
42 | | - - name: Copy cache |
43 | | - run: cat ~/.cache/binenv/cache.json | jq . > distributions/cache.json |
44 | | - if: ${{ env.DIFF != 0 }} |
| 39 | + git config user.name "github-actions[bot]" |
| 40 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
45 | 41 |
|
46 | | - - name: Update cache |
47 | | - uses: test-room-7/action-update-file@v1 |
48 | | - if: ${{ env.DIFF != 0 }} |
49 | | - with: |
50 | | - file-path: distributions/cache.json |
51 | | - commit-msg: automatic cache update |
52 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + git add distributions/cache.json |
| 43 | + git commit -m "chore: nightly cache refresh" |
| 44 | + git push |
0 commit comments