是否可以在 GitHub Actions 中更新预装的 ubuntu-latest 映像中的版本?

问题描述 投票:0回答:1

根据

他们的文档
,GitHub Actions 中的 ubuntu-latest 运行器默认使用 Yarn v1。我想将其覆盖到 Yarn 4。这可能吗?如果是,我应该查找路径来更新它吗?

github-actions yarnpkg
1个回答
0
投票

我建议您使用自定义容器,您可以在其中控制运行管道时要使用的版本。这是我写的 Ubuntu Dockerfile:

FROM ubuntu:latest
ARG NODE_MAJOR_VERSION=20
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

RUN apt update && apt install ca-certificates curl gnupg nodejs npm -y

WORKDIR /usr/app
COPY ./ /usr/app
RUN npm install -g corepack
RUN corepack enable && \
    yarn init -2 && \
    yarn set version stable && \
    yarn install


RUN echo $(yarn -v)

您可以通过构建 Dockerfile,将其放入某个注册表中,然后在管道中使用

container
选项来使用它。我建议根据口味进行编辑,因为我不知道您的项目设置。这都是从这里嘲笑的。

    container:
      image: docker://ghcr.io/<OWN-REG-HERE>/<OWN-IMG>:<TAG>
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

或者,您可以尝试在管道本身中升级版本。这应该是可能的,但我建议在图像中包含依赖项,以便您拥有最新的工作副本

© www.soinside.com 2019 - 2024. All rights reserved.