This will be a quick tip.

Some days ago, configuring a pipeline inside Github Actions I had the need to use a file generated by a job in another job, that are using distinct OS.

It’s pretty straight forward do that, the only thing that you need is the upload-artifact and the download-artifact actions

Here is an example:

job1:

  runs-on: ubuntu-latest
  steps:
  - uses: actions/checkout@v1

  - run: mkdir -p dist

  - run: echo hello > dist/world.txt

  - uses: actions/upload-artifact@master
    with:
      name: hello-world-artifact
      path: dist/world.txt

job2:
  runs-on: macos-latest

  steps:
  - run: mkdir -p dist

  - uses: actions/download-artifact@master
    with:
      name: hello-world-artifact
      path: dist/world.txt

  - run: cat dist/world.txt

Source code and documentation for the actions:

BONUS TIP I had the need to fetch a file from the Github Releases as well and to do that I used the third-party action dsaltares/fetch-gh-release-asset@master, but the drawback is that action only runs on Linux (because of that I have to copy an artifact from one job to another one ;-) )

Here is an example:

uses: dsaltares/fetch-gh-release-asset@master
with:
  repo: "your-user/your-repo"
  version: "latest"
  file: "package.zip"
  target: "dist/package.zip"
  token: ${{ secrets.YOUR_TOKEN }} # If your repo is private, you need to fill with the personal access token

Source code and documentation for the dsaltares/fetch-gh-release-asset action

That’s all folks! Thank you and stay in tune for more tips.