Hashim
Hashim

Reputation: 189

Need to set environment in github actions

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?

Upvotes: 3

Views: 2165

Answers (2)

peterevans
peterevans

Reputation: 42210

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.

Upvotes: 2

joseph
joseph

Reputation: 1008

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.

Upvotes: 1

Related Questions