How I can pass parameter inputs.custom
to this actions code:
jobs:
test-custom:
name: Test Custom
uses: ./.github/workflows/work4-${{ inputs.custom }}.yml
Fully working example:
First workflow work1-build.yml
:
name: Start workflow fail
on: [push]
jobs:
build-fail:
name: Build with other workflow
uses: ./.github/workflows/work3-build-fail.yml
with:
custom: custom-name1
Second workflow work3-build-fail.yml
:
name: Build fail with input test
on:
workflow_call:
inputs:
custom:
description: Some custom string
required: true
type: string
jobs:
test-custom:
name: Test Custom
uses: ./.github/workflows/work4-${{ inputs.custom }}.yml
Third workflow work4-custom-name1.yml
name: Custom 1
on:
workflow_call
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "IN CUSTOM 1"
Example above make GitHub respond with an error:
Invalid workflow file
error parsing called workflow
".github/workflows/work1-build.yml"
-> "./.github/workflows/work3-build-fail.yml" (source branch with sha:720087c8794e76f52277f9b1229b44ea65ab89d5)
--> "./.github/workflows/work4-${{ inputs.custom }}.yml"
: failed to fetch workflow: workflow was not found.
I can successfully add ${{ inputs.custom }}
to:
test-print:
runs-on: ubuntu-latest
name: Print input
steps:
- name: Step print input
run: echo ${{ inputs.custom }}
Docs doesn't contain any examples with uses
parametrisation:
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses
I found documentation that proves this isn't possible. There is no supporting info stating that the uses
key has access to any contexts.
See: https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
I believe this is an architectural limitation of GitHub Actions, it appears they want to resolve all workflows/actions at the start of all jobs and thus dynamic resolution isn't possible.