【发布时间】:2021-03-16 22:50:40
【问题描述】:
我有一个简短的问题,但我找不到关于它的文档(也许不可能) 如何检索从容器中构建的内容(像这样):
prod-dependencies:
name: Production Dependencies
runs-on: ubuntu-20.04
container: elixir:1.11-alpine
env:
MIX_ENV: prod
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Retrieve Cached Dependencies
uses: actions/cache@v2
id: mix-prod-cache
with:
path: |
${{ github.workspace }}/deps
${{ github.workspace }}/_build
key: PROD-${{ hashFiles('mix.lock') }}
- name: Install Dependencies
if: steps.mix-prod-cache.outputs.cache-hit != 'true'
run: |
apk add build-base rust cargo
mix do local.hex --force, local.rebar --force, deps.get --only prod, deps.compile
我需要在 Alpine 上构建,因为我在 Alpine 上进行部署,并且某些 C 库对于 Erlang VM 的工作是不同的。
所以这里是我构建依赖项的地方,我想将它们放在缓存中以供后续作业使用,但缓存永远不会填充。根据 doc GitHub 安装一个带有容器的卷来检索工件,但我必须错过使用它。
非常感谢您的帮助。
【问题讨论】:
-
请记住,Github 操作/缓存的范围仅限于特定的 分支(有一些注意事项,请注意回退到 repo 的默认分支上的缓存)。因此,如果这些作业是在不同的分支上创建的,它们可能无法用于后续作业。有关在 S3 中缓存工件以供其他分支使用的示例,请参阅 elixirforum.com/t/using-github-action-cache/37922/4。如果您的 YAML 保留正确的格式,这将有助于提高可读性。
-
感谢您的回答。我确认这些将在同一个分支上使用。主要是为了减少构建时间。
标签: caching elixir github-actions