Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reusable workflows with local actions

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

  1. Repo with reusable workflows and local action - https://github.com/vinodsai-a/github-reusable-workflow-sample
  2. Sample repo which uses above reusable workflows - https://github.com/vinodsai-a/github-example-repo

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

enter image description here

like image 466
Vinod Sai Avatar asked Dec 04 '25 15:12

Vinod Sai


1 Answers

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
  1. Check-out the repo of the called workflow to 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 }}
  1. (optional) if you want your calling repo checked out, do so, but to a subdirectory
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          path: app
  1. Start referencing your local actions:
      - uses: ./workflows/actions/your-action
like image 188
hanz_kay Avatar answered Dec 06 '25 10:12

hanz_kay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!