d3vpasha
d3vpasha

Reputation: 528

Github Actions : share steps across jobs

In my Github actions workflow, I have a job where I install eksctl :

  install-cluster:
    name: "staging - create cluster"
    runs-on: ubuntu-latest
    steps:

  - name: Setup eksctl
    run: |
      curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
      sudo mv /tmp/eksctl /usr/local/bin

I have then another job (within the same workflow) where I deploy some applications. How can I use eksctl installation step in my second job. Currently, I add a step in my second job to have eksctl installed. Is the cache the only way of doing this ? Like I install a tool & keep its binaries in the cache & get it back in my second job ?

Upvotes: 1

Views: 2084

Answers (1)

javierlga
javierlga

Reputation: 1650

A GitHub action job will run on its own runner, which means you can't re-use a binary in your second job that was installed in your first job. If you want to make it available without having to reinstall it, you'll likely have to use an action to upload[1] and download[2] the artifact in your second job.

If you'd like to cache the binary within the same job, and re-use it in other steps you can set up https://github.com/actions/cache

References:

  1. https://github.com/actions/upload-artifact
  2. https://github.com/actions/download-artifact

Upvotes: 2

Related Questions