Checkout private repository from workflow call doesn't work #1841
Answered
by
alexrosenfeld10
alexrosenfeld10
asked this question in
Q&A
-
Per title, checkout fails when called from reusable workflows. Main workflow: name: My thing
on:
pull_request:
branches:
- staging
- master
merge_group:
jobs:
changed-files:
name: Check for relevant changes
uses: ./.github/workflows/changed_files.yml
with:
files: |
blah/**
other/**
permissions:
pull-requests: read
# secrets: inherit # fails with and without this Reusable workflow (as in, on:
workflow_call:
inputs:
files:
description: "Globs of file paths, separated by newlines"
type: string
required: true
outputs:
has_changes:
description: "Whether there are changes in the files"
value: ${{ jobs.changed-files.outputs.has_changes }}
jobs:
changed-files:
name: Check files
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.changed-files-step.outputs.all_changed_files != '' }}
steps:
- name: Checkout repo if triggered by merge queue # This is the part that fails!
# if: github.event_name == 'merge_group' # commented out for testing on PRs
uses: actions/checkout@v4
with:
fetch-depth: 0
# token: ${{ secrets.GITHUB_TOKEN }} # fails with this
# token: ${{ secrets.GITHUB_TOKEN_FOO }} # fails with this when passed directly as well
- id: changed-files-step
uses: tj-actions/changed-files@v44
with:
files: ${{ inputs.files }} I've tried:
Checkout works from the parent job by the way. It's just when called from the reusable workflow that it fails. Error log:
|
Beta Was this translation helpful? Give feedback.
Answered by
alexrosenfeld10
Aug 2, 2024
Replies: 1 comment 1 reply
-
I've also tried permissions: read-all
secrets: inherit to no avail |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ugh, the permissions have to be on the reusable workflow, not the top level workflow. GHAs can be so needlessly complex in their configuration