on master help sign in
try caching
commite7cc929d40c49bc8381d1a8e0faaa0dacdc88245 authoriko <ilyakooo0@gmail.com> dateTue 21 Dec 2021, 14:11 (5 years ago) parentda4a542
5 files changed+57−28
.github/actions/common_setup/action.yaml+6−7 .github/actions/nix_cache/action.yaml+25 .github/actions/nix_cache_post/action.yaml+10 .github/actions/push_docker_images/action.yaml−20 .github/workflows/github-actions-image.yaml+16−1
.github/actions/common_setup/action.yaml+6−7
@@ -1,8 +1,8 @@
11name: "Common setup"
22description: "Common setup steps"
33inputs:
4− cachixSigningKey:
5− description: "Cachix signing key"
4+ key:
5+ description: "Caching key"
66 required: true
77runs:
88 using: "composite"
@@ -15,8 +15,7 @@ runs:
1515 trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
1616 substituters = https://hydra.iohk.io https://cache.nixos.org/
1717
18− # - name: Login to Cachix
19− # uses: cachix/cachix-action@v10
20− # with:
21− # name: octopod
22− # signingKey: ${{ inputs.cachixSigningKey }}
18+ - name: Cache Nix
19+ uses: ./.github/actions/nix_cache
20+ with:
21+ key: ${{ inputs.key }}
.github/actions/nix_cache/action.yamlnew file+25
@@ -0,0 +1,25 @@
1+name: "Nix cache"
2+description: "Cache nix build"
3+inputs:
4+ key:
5+ description: "Caching key"
6+ required: true
7+runs:
8+ using: "composite"
9+ steps:
10+ - name: Cache Nix
11+ id: cache-nix
12+ uses: actions/cache@latest
13+ with:
14+ path: |
15+ ~/nix/store
16+ key: ${{ inputs.key }}
17+ - name: Move nix cache
18+ shell: bash
19+ env:
20+ CACHE_HIT: ${{ steps.cache-nix.outputs.cache-hit }}
21+ run: |
22+ if [[ "$CACHE_HIT" == 'true' ]]; then
23+ sudo mkdir -p $NIX_STORE
24+ sudo mv -f ~/nix/store/* /nix/store/
25+ fi
.github/actions/nix_cache_post/action.yamlnew file+10
@@ -0,0 +1,10 @@
1+name: "Nix cache post"
2+description: "Cache nix build post"
3+runs:
4+ using: "composite"
5+ steps:
6+ - name: Move nix cache
7+ shell: bash
8+ run: |
9+ mkdir -p ~/nix/store
10+ sudo mv -f /nix/store/* ~/nix/store/
.github/actions/push_docker_images/action.yamldeleted−20
@@ -1,20 +0,0 @@
1−name: "Push Docker Images"
2−description: "Push Docker Images"
3−inputs:
4− tag:
5− description: "The docker image tag to push."
6− required: true
7− docker_username:
8− description: "The Docker Hub username"
9− required: true
10− docker_password:
11− description: "The Docker Hub password"
12− required: true
13−runs:
14− using: "composite"
15− steps:
16− - name: Push Docker Images to DockerHub
17− shell: bash
18− run: |
19− skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto) docker://typeable/comparest-github-action:${{ inputs.tag }}
20− skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto) docker://typeable/comparest:${{ inputs.tag }}
.github/workflows/github-actions-image.yaml+16−1
@@ -29,7 +29,9 @@ jobs:
2929 submodules: recursive
3030
3131 - name: Common setup
32− uses: ./.github/actions/common_setup
32+ uses: ./.github/actions/nix_cache
33+ with:
34+ key: Linux-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
3335
3436 - name: Build Linux static binary
3537 shell: bash
@@ -80,6 +82,9 @@ jobs:
8082 skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto) docker://typeable/comparest-github-action:${{ github.event.payload.name }}
8183 skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto) docker://typeable/comparest:${{ github.event.payload.name }}
8284
85+ - name: Cache Nix post
86+ uses: ./.github/actions/nix_cache_post
87+
8388 macOS:
8489 runs-on: macos-latest
8590 steps:
@@ -89,6 +94,8 @@ jobs:
8994
9095 - name: Common setup
9196 uses: ./.github/actions/common_setup
97+ with:
98+ key: macOS-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
9299
93100 - name: Build macOS binary bundle
94101 run: |
@@ -100,6 +107,9 @@ jobs:
100107 name: compaREST-macOS
101108 path: compaREST
102109
110+ - name: Cache Nix post
111+ uses: ./.github/actions/nix_cache_post
112+
103113 Linux-Windows:
104114 runs-on: ubuntu-latest
105115 steps:
@@ -121,6 +131,8 @@ jobs:
121131
122132 - name: Common setup
123133 uses: ./.github/actions/common_setup
134+ with:
135+ key: Linux-Windows-${{ hashFiles('**.nix') }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
124136
125137 - name: Build Windows binary
126138 run: |
@@ -137,3 +149,6 @@ jobs:
137149 with:
138150 name: compaREST-Windows
139151 path: compaREST
152+
153+ - name: Cache Nix post
154+ uses: ./.github/actions/nix_cache_post