1

I have a query in regards with Github workflows.

Consider the below scenario :

  • Github Organization 1 : sample_one

  • Github Organization 2 : sample_two

  • sample_one organization has one repository called : one_repo

  • sample_two organization has one repository called : two_repo

Problem Statement :

one_repo has a reusable workflow that needs to be called by two_repo (that is in different organization) - How do I do this?

Note :

The reusable workflow from one_repo maybe updated from time to time.

Can someone help me with the workflow calls for the same as to how can a repo from some other organization be able to call the resuable workflow from another organization.

1 Answer 1

0

First, you must permit the reusable workflow to be called from another organization.
For that, go to Organization settings -> Actions -> General. Under the policies, select the "Allow all actions and reusable workflows" option to use the workflow outside the organization.

NOTE: You have to keep the repositories public so that the other organizations can access them.

org-settings

Now to the work:

  1. Create a reusable workflow in the GitHub Organization 1: sample_one.
  2. Now create a trigger workflow in two_repo to call the workflow in one_repo under sample_one organization.
  3. Now add the trigger parameter under the jobs section inside the workflow and mention the reusable workflow of one_repo.
name: Scan, Build and Deploy
on:
  push:
    branches: [ "main" ]

jobs:
  trigger:
    uses: sample_one/one_repo/.github/workflows/reusable-workflow.yml@main

Edit the following line according to the location of the reusable workflow.

That's it! So when the workflow runs in the two_repo, the reusable workflow in the one_repo will be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.