需要在github动作中设置环境 [英] Need to set environment in github actions

查看:83
本文介绍了需要在github动作中设置环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次工作流运行时,我都需要安装几个cli,这会花费大量时间进行安装,然后构建和发布该程序包。每次摆脱安装的一些好的替代方法是什么?

I need to install a couple of cli's every time the workflow runs, it takes up a lot of time in installation and then building and publishing the package. What are some good alternatives to get rid of installation every time?

推荐答案

要扩展@joseph的答案,请创建一个Docker该映像使用所需的CLI工具准备环境,然后将其发布到DockerHub。注意不要包含任何秘密,因为该图像必须是公开的,GitHub Actions才能使用它。

To expand on the answer by @joseph, create a Docker image that prepares an environment with the CLI tools that you need and then publish it to DockerHub. Take care not to include any secrets as the image must be public for GitHub Actions to make use of it.

在您的工作流程中,设置作业以使用容器具有以下语法。
https://help.github。 com / zh-CN / articles / workflow-syntax-for-github-actions#jobsjob_idcontainer

In your workflow set up the job to use a container with the following syntax. https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idcontainer

eg

jobs:
  my_job:
    container:
      image: node:10.16-jessie
      env:
        NODE_ENV: development
      ports:
        - 80
      volumes:
        - my_docker_volume:/volume_mount
      options: --cpus 1

此作业中的工作流程步骤将在容器的上下文中执行,并可以访问您预先安装的工具。

Workflow steps in this job will then execute in the context of your container and have access to the tools you have pre-installed.

这篇关于需要在github动作中设置环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆