Issue not created and Action shows `Unexpected input 'repo-token', valid inputs are ['joke', 'issue-title']` warning

I’m currently stuck on the final step in the Writing Javascript Actions course where there is no issue created as expected in the Issues tab. In the Actions tab there is an error that reads Unexpected input 'repo-token', valid inputs are ['joke', 'issue-title']

I can’t see anything wrong in terms of possible typo(s) and nothing obviously wrong sticks out either.

Sorry about that, @kopijunkie! I’ve opened an issue in the course repo to address this.

@kopijunkie I’d love to help you out with this! I took a quick look at your pull request and have identified the problem.

The problem

The problem here is that your issue-maker action is trying to use an input named repo-token and it doesn’t know what that means.

To create custom JS actions there are two files needed:

  1. The JS source code for the action
  2. The action metadata

We will look at each quickly so we can get you back on track!

Source code

    const issueTitle = core.getInput("issue-title");
    const jokeBody = core.getInput("joke");
    const token = core.getInput("repo-token");

    const octokit = new github.GitHub(token);

Currently your source code is perfect :+1:, which means great job to you :tada:!

As you’ll see, you are creating a variable named token which uses the core.getInput() method to read an input named repo-token.

So the real question becomes… where does that “read” happen from :thinking:?

Action metadata

Let’s keep that question in mind while we talk about the action metatdata!

You’ll probably recall that every custom action, even Docker container actions, need a file named action.yml. They absolutely under all circumstances NEED this file!

But why is this file so important?

I’m glad you asked. This file is what interfaces between the :point_up: JS source code and the workflow file in the repository.

So it is in the action.yml that we must specify ALL of the inputs our actions is allowed to receive BEFORE we are able to read them in our source code!

Let’s look at the action.yml file for you issue-maker action

name: "I have issues"

description: "consume the output of the previous action and create a new issue in the repository"

inputs:
  joke:
    description: "This will become the body of the created issue"
  issue-title:
    description: "Every issue needs a title, it's nice to supply one, even though you could do this dynamically within your code"
    default: "a joke for you"
    required: true

runs:
  using: "node12"
  main: "index.js"

:thinking: Hmmm, something isn’t right!

You currently only have two inputs

  • joke
  • issue-title

Which means that your source code has no idea how to use getInput('repo-token') because it is not defined in the action.yml.

The solution.

The good news is that the problem wasn’t your fault at all!

Rather it was a misstep on our end of things. To solve the problem you’ll need to add an input for repo-token to your action.yml file and then the course should move along just fine for you.

I’ve included a sample file below that should accomplish this.

Let me know if there is anything else I can help you with :heart:

name: "I have issues"

description: "consume the output of the previous action and create a new issue in the repository"

inputs:
  joke:
    description: "This will become the body of the created issue"
  issue-title:
    description: "Every issue needs a title, it's nice to supply one, even though you could do this dynamically within your code"
    default: "a joke for you"
    required: true
  repo-token:
    description: "Token with permissions to do repo things"

runs:
  using: "node12"
  main: "index.js"
1 Like

Hi @mattdavis0351

Thanks for your response & the detailed explanation of the problem and the solution. Really helped me to understand things better.

I’ve now got the action creating an issue with a joke when a label’s added.

Only thing is I found I had to make a change in the .github/workflows/my-workflow.yml file to get the joke output for the issue body. Basically if you have a look at the issues created by the action in my repo up until the most recent one the issues were being created with an empty body.

It looks like defining joke as ${{steps.jokes.outputs.joke-output}} in the workflow was not getting any joke output until I made these changes:

  1. Changed ha-ha step to be named jokes instead
  2. Use id instead of name for the step name