Error running reusable workflows - Github actions

Viewed 82

I want to use reusable workflows and invoke two other actions, below is the snippet of both caller and called workflows:

az-dev-img-ops-reusable.yml (called workflow1)

on:
  workflow_call:
    inputs:
      cloudProvider:
        required: true
        type: string
      imgAction: 
        required: true
        type: string
      envName: 
        required: true
        type: string
      productImage: 
        required: true
        type: string        
jobs:
  image-actions:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/workflows/manage_images
        with:
          imgAction: ${{ inputs.imgAction }}
          cloudProvider: ${{ inputs.cloudProvider }} 
          envName: ${{ inputs.envName }}
          productImage: ${{ inputs.productImage }}


az-dev-tenant-ops-reusable.yml (called workflow2)

on:
  workflow_call:
    inputs:
      cloudProvider:
        required: true
        type: string
      envName: 
        required: true
        type: string    
      action: 
        required: true
        type: string      
jobs:
  tenant-actions:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/workflows/refresh_tenant
        with: 
          cloudProvider: azure
          envName: az-dev
          action: pod_refresh

az-dev-cicd.yml (caller workflow)

on:
  workflow_dispatch:

jobs:
  init:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
  image-operations:
    uses: ./.github/workflows/az-dev-img-ops-reusable.yml
    with:
      imgAction: check 
      cloudProvider: azure 
      envName: az-dev 
      productImage: my-server
  tenant-operations:
    needs: image-operations
    uses: ./.github/workflows/az-dev-tenant-ops-reusable.yml
    with: 
      cloudProvider: azure
      envName: az-dev
      action: pod_refresh

But while running, it throws error as below:

Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/opt/my-runner/_work/my-images/my-images/.github/workflows/manage_images'. Did you forget to run actions/checkout before running your local action?

Checked over the web for solutions and tried all i.e.

  1. Have a actions/checkout.
  2. Make sure the caller function makes use of "uses" and not steps.
  3. Tried both absolute path of repo/yaml and relative path.

But haven't been able to resolve it. Any hints/help would be highly appreciated.

1 Answers

Your issue is that you used the following syntax:

uses: ./.github/workflows/manage_images

... that refers to a directory.

When used that way, the Github Action interpreter expect a local action (using an action in the same repo).

However, to use local actions, you need to create a action.yaml file in a directory, but in your case, the image you shared in the comment shows that you actually have a manage_images.yaml file, that refers to a workflow, not a manage_images folder with an action.yml file in it.

To resolve your issue, if this manage_images.yaml is a reusable workflow (reusing the same workflow in different workflows), you need to add .yaml at the end of uses step, like this:

uses: ./.github/workflows/manage_images.yaml

Or, if you actually want to use a local action, convert this manage_images.yaml workflow to an action.yaml file, and put it inside a .github/workflows/manage_images directory.

Note that this answer could also give you more context about local actions and reusable workflows.

Related