Consider the below scenario:
sample_one
organization has one repository calledone_repo
sample_two
organization has one repository calledtwo_repo
one_repo
has a reusable workflow that needs to be called by two_repo
, which is in different organization - how do I do this?
The reusable workflow from one_repo
may be updated from time to time.
Here is the sample code: my_template.yml (reusable workflow):
name: Reusable Workflow
on:
workflow_call:
inputs:
config-path:
required: true
type: string
push:
branches:
- main
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Py
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Req
run: |
pip install -r requirements.txt
- name: Run Pytest
run: |
echo "Input Value: ${{ inputs.config-path }}"
pytest
test.yml (thats calling the parent workflow that is in different organization):
name: Reuse Workflow in current
on:
push:
branches:
- main
jobs:
trigger-the_one-workflow:
uses: parent-org/repo_one/.github/workflows/my_template.yml@main
with:
config-path: "qa"