1

I am learning Github actions and getting an error when I use a composite action.

Here is my github workflow file:

      - name: Step1
        id: action-file
        uses: ./.github/action/module
        with:
          my_name: "PythonTest"

And Here is action file:

  using:  composite
  steps:
    - name: Step1
      run: print ("Hello" + ${{ inputs.my_name }})
      shell: python

I am getting the below error when I execute:

Warning: Unexpected input(s) 'my_name', valid inputs are ['']
Run ./.github/action/module
Traceback (most recent call last):
  File "/home/runner/work/_temp/51be3e25-aa9b-4e7b-a9ff-80070e4f7754.py", line 1, in <module>
    print ("Hello" + PythonTest)
NameError: name 'PythonTest' is not defined
1
  • As the warning points out, try to replace "PythonTest" with 'PythonTest' Commented Jul 22, 2021 at 8:23

1 Answer 1

3

YAML is parsing out your "". As you can see in the error, PythonTest is passed as a symbol, not a string. You need to modify your template in order to accommodate for this:

  using:  composite
  steps:
    - name: Step1
      run: print ("Hello" + "${{ inputs.my_name }}")
      shell: python

Whatever is between the ${{}} template will be replaced, and your test will output "HelloPythonTest"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.