Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 5

Local Action not found in workflow

Solved! Go to Solution.

I have my main workflow (/.github/workflows/builds.yml) :

 

jobs:
  job1:
    name: PT.M Android Build
    runs-on: macos-latest
    steps:
      - name: Clone Repo
        uses: actions/checkout@v1

      - name: Shared Setup
        uses: ./.github/actions/shared-setup/shared-setup

Attempting to use a local action that runs other actions that end up being duplicated across other jobs in the same workflow. I'm trying to avoid duplicating a lot of the same process in my CI Builds by having a local action to call that runs the same steps needed when executed.

 

I've simplified my local action to this (/.github/actions/shared-setup.yml) :

 

- name: Setup SSH-Agent
  uses: webfactory/ssh-agent@v0.2.0
  with:
    ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup JDK 1.8
  uses: actions/setup-java@v1
  with:
    java-version: 1.8

When I run the checks the following error happens:

 

##[error]Can't find 'action.yml' or 'Dockerfile' under '/Users/runner/runners/2.163.1/work/permobil-client/permobil-client/.github/actions/shared-setup'. Did you forget to run actions/checkout before running your local action?

I stumbled on this topic https://github.community/t5/GitHub-Actions/Path-to-action-in-the-same-repository-as-workflow/td-p/38... but from the answer and the docs I assume I have everything configured correctly. I'm running checkout prior to running my local action.

 

Any ideas?

4 Replies
Copilot Lvl 2
Message 2 of 5

Re: Local Action not found in workflow

I did successfully find the action now, however, maybe this approach is wrong for what I'm doing.

 

1. an action needs the action.yml metadata file

2. My uses statement would be 

      - name: Shared Setup
        uses: ./.github/actions/shared-setup

So now my workflow does find the action but another issue is introduced:

 My main workflow runs on `macos-latest` and I'm unsure how to run a local action with this workflow.

 

It's possible I'm trying to use a local action in a way that is not supported. At the end of the day I'm just trying to reduce duplication across jobs. I was unable to get YAML aliases working with github actions (assumed not supported) so I thought maybe using a local action would help keep my workflow DRY. Instead of repeating the same setup steps in 4 jobs.

Highlighted
Solution
GitHub Partner
Message 3 of 5

Re: Local Action not found in workflow

Your request is similar to set up job/step templates which can be referenced in workflow definitions. But as I have mentioned in this ticket, currently GitHub Actions does not support job/step templates.

Maybe you can try to encapsulate the repeated steps into one action, for example if the repeated steps are executing some command lines, so that you just need to use this action in each job. However, most of the time, it is very hard and troublesome to encapsulate multiple jobs/steps into one action.

 

I recommend that you can directly report a feature request here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

Highlighted
Copilot Lvl 2
Message 4 of 5

Re: Local Action not found in workflow

I think all of us would love this feature. Just today the team I’m on asked if we can reuse this instead of copy pasting for minor differences in workflow.
Highlighted
Ground Controller Lvl 1
Message 5 of 5

Re: Local Action not found in workflow

Do we need to crate a folder named actions parallel to workflow folder here? and if so, what should actions folder consists of?

below is my .yml file

 

name: Dart CI

on:
  push:
    branches: [ feature/tests ]
  pull_request:
    branches: [ feature/tests ]

jobs:
  test:
    name: Test on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-java@v1
        with:
          java-version: '12.x'
      
      #  Integration test for home page empty state
      #- uses:  what is the path I should write here.
        with:
          token: '${{ secrets.GITHUB_TOKEN }}'
      - run: flutter drive --target=test_driver/listing_details/home_tab/home_tab_empty_state.dart


Highlighted circle is the hierarchy of the action files in my repo.

Annotation 2020-04-02 184109.png