In a GitHub shared action, is it possible to know the full name (with owner) of the repo from which the action has been called?
For instance with two repos:
owner/caller/.github/actions/action1.yml
...
steps:
- name: Checkout action
uses: actions/checkout@v4
with:
repository: owner/called
ref: main
path: ./shared-workflows
sparse-checkout: .github/workflows
sparse-checkout-cone-mode: false
- name: Use reusable workflow2
uses: ./shared-workflows/.github/workflows/shared
owner/caller/.github/actions/called/action.yml
:
...
runs:
using: "composite"
steps:
- name: echo
shell: bash
run: |
echo SOMETHING
And the shared action should echo owner/caller
.
Variable | Description | Example Value |
---|---|---|
${{ github.repository }} | Full repo path (owner/repo) | owner/caller |
${{ github.repository_owner }} | Just the owner (organization/user) | owner |
${{ github.event.repository.name }} | Just the repository name (no owner) | caller |
Example composition action:
# .github/actions/called/action.yml
name: "Called Action"
description: "An action that knows who called it"
runs:
using: "composite"
steps:
- name: Echo caller repository
shell: bash
run: |
echo "Caller repository: ${{ github.repository }}"
echo "Caller owner: ${{ github.repository_owner }}"
echo "Caller repo name: ${{ github.event.repository.name }}"
This allows your shared action to respond differently depending on the caller — useful for logging, access control, repo-specific logic, or telemetry.
Bonus point: If you're using this in a reusable workflow (via workflow_call), these variables still work, but if you're trying to explicitly pass these into a called action or workflow, you can also pass them as inputs:
# In the caller workflow
uses: owner/repo/.github/workflows/reusable.yml@main
with:
caller_repo: ${{ github.repository }}