Need to set environment in github actions

爷,独闯天下 提交于 2019-12-24 03:36:14

问题


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?


回答1:


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.

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

e.g.

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.




回答2:


I assume github actions use docker container in different workflow stages. If thats the case instead of relying on standard containers available, use your own docker images, which is pre-baked with the static software components like cli you need.

For getting going fast, take the current Dockerfile you use and add the install commands, build and push to docker hub or github registry. Later on you can take bare minimum image and install only the minimal software you need.



来源:https://stackoverflow.com/questions/58281558/need-to-set-environment-in-github-actions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!