Skip to content

Commit

Build with artifacts and cache, and follow it

syntaqxcommitted Parent1eadc99Browse files
2 files+45−00/2 viewed
+10−0
1+name: After build
2+on:
3+ workflow_run:
4+ workflows: [Build]
5+ types: [completed]
6+jobs:
7+ report:
8+ runs-on: ubuntu-latest
9+ steps:
10+ - run: echo "Build ${{ github.event.workflow_run.run_number }} finished with ${{ github.event.workflow_run.conclusion }} on ${{ github.event.workflow_run.head_branch }}"
+35−0
1+name: Build
2+on:
3+ push:
4+ branches: [main]
5+ workflow_dispatch:
6+jobs:
7+ build:
8+ runs-on: ubuntu-latest
9+ steps:
10+ - uses: actions/checkout@v4
11+ - name: Restore the cache
12+ id: cache
13+ uses: actions/cache@v4
14+ with:
15+ path: .deps
16+ key: deps-${{ hashFiles('math.js') }}
17+ restore-keys: deps-
18+ - name: Fill the cache on a miss
19+ if: steps.cache.outputs.cache-hit != 'true'
20+ run: mkdir -p .deps && date > .deps/made-at && echo "cache was cold"
21+ - run: echo "cache hit=${{ steps.cache.outputs.cache-hit }}; deps made at $(cat .deps/made-at)"
22+ - run: mkdir -p dist && cp math.js dist/ && echo "built $(date)" > dist/BUILD
23+ - uses: actions/upload-artifact@v4
24+ with:
25+ name: dist
26+ path: dist/
27+ verify:
28+ needs: build
29+ runs-on: ubuntu-latest
30+ steps:
31+ - uses: actions/download-artifact@v4
32+ with:
33+ name: dist
34+ path: out
35+ - run: ls -la out && cat out/BUILD && node -e "console.log(require('./out/math.js').add(2, 2))"