Reputation: 2122
Reusable workflows with local actions are not working. Reusable workflow is trying to locate the local action in the main repo
Created sample repositories to reproduce the issue
This is the PR link -> https://github.com/vinodsai-a/github-example-repo/pull/1
Error -> https://github.com/vinodsai-a/github-example-repo/pull/1/checks
Upvotes: 18
Views: 23046
Reputation: 121
I support the answer by [https://stackoverflow.com/users/8496462/guifalourd] and it needs
But, the particular error message "Did you forget to run actions/checkout before running your local action?" can be caused by below reason as well, if you are calling a local action in your own repository.
If You are not specifying correct path till the folder in which your action is written.
For example:
./ <THIS_IS_YOUR_PROJECT_ROOT_DIR>
./.github/actions/upload-to-jfrog/action.yml
It needs the exact folder path till that action.yml file
Upvotes: 0
Reputation: 22890
The issue here is that you can't call a local action on a repository without using the actions/checkout action to access the files in the repository.
on: [workflow_call]
jobs:
local-action-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected] # Necessary to access local action
- uses: ./actions/local-action
I've got some proofs of concept here if you want to take a look:
Upvotes: 10
Reputation: 141
Update: you can use below workaround on github.com and GHE Server v3.9+ without the input 'workflows-ref' and instead use github.workflow_ref
(doc) or the env-var GITHUB_WORKFLOW_REF
(doc). thanks @Philip Couling
There is a workaround, it comes however with the downside of needing to specify the ref for the reusable workflow twice, like this:
jobs:
build-push:
uses: <org>/<central-workflow-repo>/.github/workflows/[email protected] # always change with.workflows-ref, too
with:
workflows-ref: v1.2
secrets:
# can't use GITHUB_TOKEN as its different repo
GH_ACCESSTOKEN: ${{ secrets.GH_ACCESSTOKEN }}
The repo of your reusable workflow has this structure:
<org>/<central-workflow-repo>/ (github repo)
├─ .github/
│ ├─ workflows/
│ │ ├─ build-push.yml
├─ actions/
│ ├─ your-action/
│ │ ├─ action.yml
workflows
on:
workflow_call:
inputs:
workflows-ref:
description: "ref of the centralized workflows repo that was specified in 'jobs.<name>.uses'"
required: true
type: string
...
steps:
- name: Checkout workflows repo # required so we can reference the actions locally
uses: actions/checkout@v2
with:
ref: ${{ inputs.workflows-ref }}
path: workflows
repository: <org>/<central-workflow-repo>
token: ${{ secrets.GH_ACCESSTOKEN }}
- name: Checkout repository
uses: actions/checkout@v2
with:
path: app
- uses: ./workflows/actions/your-action
Upvotes: 14
Reputation: 1055
I also had this issue.
When using local actions they need to be placed at the job level (NOT inside the steps of a job). Your caller action should be changed from:
on: [pull_request]
jobs:
ci:
uses: vinodsai-a/github-reusable-workflow-sample/.github/workflows/main.yml@main
to:
on: [pull_request]
jobs:
uses: vinodsai-a/github-reusable-workflow-sample/.github/workflows/main.yml@main
Reference: https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow
Upvotes: -1
Reputation: 2762
I don't think as of now GitHub allows any way to use actions from reusable workflow repo. Currently. reusable workflow functionality is very limited and all the actions in the reusable workflow run as part of the caller workflow. So when you are specifying to run action in path ./actions/local-action
GitHub action is trying to find the action in your caller repo and since the path isn't valid for caller repo you are getting the error.
The current workaround is treat your action as if it is hosted in external repo instead of local path as documented.
In your case you can specify vinodsai-a/github-reusable-workflow-sample/actions/local-action@main
instead of ./actions/local-action
.
Upvotes: 4
Reputation: 1
I do not believe this is possible at this point in time. You may consider posting your query at https://github.community/c/code-to-cloud/52 to get better visibility to this request.
Upvotes: 0