Trying to refer a Reusbale Workflow from a Private repo

Viewed 24

I am trying to find a workaround for using a Reusable workflow between two private repos: (It is not supported natively)

Context: I am trying to use a central repo (private) to contain all the Workflows and refer to that location from other repos (private).

Legend: Central Repo: Contains all the Reusable Workflows. (If we edit a file in here we should not have to edit each and every repo's workflow files) Calling Repo: A repo which runs Workflows, This repo will try to refer the workflows from the Central repo.

name: Calling Reusable Workflows

on: [ push ]

jobs:
  download-remote-repo:
    runs-on: ubuntu-latest
    steps:
    - name: Get private repo with action
      uses: actions/checkout@v2
      with:
        repository: kalanatd/central-repo
        ref: main
        token: ${{ secrets.PAT_TOKEN }}
    - name: List Files After remote Checkout
      run: |
        pwd
        ls -a                 // I can see the checked out remote repo files in here
        ls -al .github/workflows
        cat ./.github/workflows/workflow.yml             // Can read the file without any issue
    - name: Run a workflow file
      uses: ./.github/workflows/workflow.yml 

Note: In aboe scenario ./.github/workflows/workflow.yml is dynamically checked out to the Runner's workspace. Even though 'run' commands can see that file 'uses' command does not use it.

[1] Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/caller-repo/caller-repo/workflow.yml'. Did you forget to run actions/checkout before running your local action?

[2] https://github.github.io/actions-cheat-sheet/actions-cheat-sheet.pdf

Note:

I learned that RWs can not be called under steps which means there is no way to download a RW from another place and use that workflow, right?

0 Answers
Related