Running multiple jobs on the same runner or sharing workspace

Is there any way we can run multiple jobs in a single runner or share the Github actions workspace between jobs?

In my organization, development teams use multiple reusable workflows created and managed by multiple teams. Team build creates and manages build.yaml that builds applications. My team creates and manages analysis.yaml that does data analysis on application builds and archives the built artifacts.

Developments teams are planning to use both of our workflows in their application workflow. For my team’s workflow to work, my workflow needs to access the built code ( target directory for maven builds, build directory for gradle builds and node_modules for npm builds).

  • Is there a way to run my reusable workflow on the runner where the code is built?
  • Is there a way I can get access to the workspace where the code is built (I searched other answers and learnt that I can use the upload action and cache action). Are there other ways I can accomplish this and run my reusable workflow on the build runner itself?
  • Will I accomplish this better with a composite action rather than using a reusable workflow?

I have the following example.

build.yaml

on:
  workflow_call
  inputs:
    build:
      description: Build type
      required: true

jobs:
  Build:
    runs-on: self-hosted
    steps:
      - name: Building apps
      - if: ${{inputs.build=='gradle'}}
        run: |
          gradle build

analysis.yaml

on:
  workflow_call
  inputs:
    analysis:
      description: Build type
      required: true
      type: boolean

jobs:
  Build:
    runs-on: self-hosted
    steps:
      - name: Building apps
      - if: ${{inputs.analysis}}
        run: |
          #Run ML build analysis
          #Archive the build artifacts

workflow.yaml

on:
  push:
    branches: [main]

jobs:
  Build:
    uses: buildteam/.github/workflows/build.yaml@main
    with:
      build: gradle

  Analysis:
    uses: analysis/.github/workflows/analysis.yaml@main
    with:
      analysis: true
1 Like