I want to use the secrets of a called workflow residing inside a different repository from the caller workflow. How can I use them?
Action 1 (Inside repo X)
name: Call GitHobbit
on:
push:
branches:
- 'main'
jobs:
call-workflow:
uses: mehtakaran9/githobbit/.github/workflows/actions.yml@main
with:
owner: mehtakaran99
repository: test-app-js
branch: main
target-branch: typescript
file-mode: false
Action 2 (Repo Y):
name: Run automated typer
on:
workflow_call:
inputs:
owner:
required: true
type: string
repository:
required: true
type: string
branch:
required: true
type: string
target-branch:
required: true
type: string
file-mode:
required: true
type: boolean
files:
required: false
type: string
working-directory:
required: false
type: string
default: '.'
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN_PAT_CLASSIC }}
jobs:
directory-typer:
runs-on: ubuntu-latest
if: ${{ inputs.working-directory }} != null && ${{ inputs.file-mode }} == false
steps:
# Add forking step
- name: Forking the repo
run: gh repo fork ${{ inputs.owner }}/${{ inputs.repository }} --clone --remote
The secret GH_TOKEN: ${{ secrets.ACCESS_TOKEN_PAT_CLASSIC }}
resides inside the repo Y action secrets.
But I get the following error when the workflow is executed:
Run gh repo fork mehtakaran99/test-app-js --clone --remote
gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable. Example:
env: GH_TOKEN: ${{ github.token }}