Compare commits

...

3 Commits

Author SHA1 Message Date
Jose Quintana
d1d9141909
Merge b045ea1d9e into 8469c94c6a 2024-10-09 10:47:51 +02:00
Jan T. Sott
8469c94c6a
Add Bun example (#1456)
* Add Bun example

* Fix Bun Windows example
2024-10-08 19:53:09 +00:00
Jose Quintana
b045ea1d9e
Add Docker example 2023-12-02 00:28:50 +01:00
2 changed files with 58 additions and 0 deletions

View File

@ -157,10 +157,12 @@ Every programming language and framework has its own way of caching.
See [Examples](examples.md) for a list of `actions/cache` implementations for use with: See [Examples](examples.md) for a list of `actions/cache` implementations for use with:
* [Bun](./examples.md#bun)
* [C# - NuGet](./examples.md#c---nuget) * [C# - NuGet](./examples.md#c---nuget)
* [Clojure - Lein Deps](./examples.md#clojure---lein-deps) * [Clojure - Lein Deps](./examples.md#clojure---lein-deps)
* [D - DUB](./examples.md#d---dub) * [D - DUB](./examples.md#d---dub)
* [Deno](./examples.md#deno) * [Deno](./examples.md#deno)
* [Docker](./examples.md#docker)
* [Elixir - Mix](./examples.md#elixir---mix) * [Elixir - Mix](./examples.md#elixir---mix)
* [Go - Modules](./examples.md#go---modules) * [Go - Modules](./examples.md#go---modules)
* [Haskell - Cabal](./examples.md#haskell---cabal) * [Haskell - Cabal](./examples.md#haskell---cabal)

View File

@ -1,5 +1,6 @@
# Examples # Examples
- [Bun](#bun)
- [C# - NuGet](#c---nuget) - [C# - NuGet](#c---nuget)
- [Clojure - Lein Deps](#clojure---lein-deps) - [Clojure - Lein Deps](#clojure---lein-deps)
- [D - DUB](#d---dub) - [D - DUB](#d---dub)
@ -9,6 +10,7 @@
- [Linux](#linux) - [Linux](#linux)
- [macOS](#macos) - [macOS](#macos)
- [Windows](#windows-1) - [Windows](#windows-1)
- [Docker](#docker)
- [Elixir - Mix](#elixir---mix) - [Elixir - Mix](#elixir---mix)
- [Erlang - Rebar3](#erlang--rebar3) - [Erlang - Rebar3](#erlang--rebar3)
- [Go - Modules](#go---modules) - [Go - Modules](#go---modules)
@ -41,6 +43,26 @@
- [Swift - Mint](#swift---mint) - [Swift - Mint](#swift---mint)
- [* - Bazel](#---bazel) - [* - Bazel](#---bazel)
## Bun
```yaml
- uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
```
### Windows
```yaml
- uses: actions/cache@v4
with:
path: |
~\.bun
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
```
## C# - NuGet ## C# - NuGet
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
@ -155,6 +177,40 @@ steps:
key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }} key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
``` ```
## Docker
```yaml
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: my-project-${{ matrix.arch }}-buildx-${{ hashFiles('my-directory/Dockerfile') }}
restore-keys: |
my-project-${{ matrix.arch }}-buildx-
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Test
uses: docker/build-push-action@v3
with:
push: false
context: .
platforms: ${{ matrix.arch }}
file: my-directory/Dockerfile
tags: my-username/my-image:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
-
# Temporary workaround
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
```
## Elixir - Mix ## Elixir - Mix
```yaml ```yaml