Skip to content

Validate required inputs are set before invoking an action #1070

@NorseGaud

Description

@NorseGaud

Describe the bug

I have the following action.yml:

name: 'Anka Prepare VM and execute inside'
description: 'Prepare an Anka VM and execute commands inside'
author: Veertu
branding:
  icon: 'anchor'
  color: 'blue'
inputs:
  anka-template:
    description: 'name or UUID of Anka Template'
    required: true

My index.js looks like:

const core = require('@actions/core');
const io = require('@actions/io');
const prepare = require('./prepare');
const execute = require('./execute');

// most @actions toolkit packages have async methods
async function run() {
  try { 
    const ankaVirtCLIPath = await io.which('anka', true)
    console.log(`Anka Virtualization CLI found at: ${ankaVirtCLIPath}`)
    const ankaTemplate = core.getInput('anka-template');
    const ankaTag = core.getInput('anka-tag');
    const ankaCommands = core.getInput('commands');
    const hostPreCommands = core.getInput('host-pre-commands');
    const hostPostCommands = core.getInput('host-post-commands');
    console.log("=========================" + "\n" + `${hostPreCommands}` + "\n" + "=================================")
    console.log("=========================" + "\n" + `${hostPostCommands}` + "\n" + "=================================")
    console.log("=========================" + "\n" + `${ankaCommands}` + "\n" + "=================================")
    if (hostPreCommands) {
      await execute.nodeCommands(hostPreCommands)
    }
    // Prepare VM
    await prepare.ankaRegistryPull(ankaTemplate,ankaTag)
    // Run commands inside VM
    // Cleanup
    if (hostPostCommands) {
      await execute.nodeCommands(hostPostCommands)
    }
  } catch (error) {
    core.setFailed(error);
  }
}

run()

and finally, the important part of my .github/workflows/test.yml:

    - name: basic commands
      id: basic
      uses: ./
      with:
        commands: |
          env
          ls -laht ./
          ls -laht ../
          pwd
          echo "HERE" && \
          echo "THERE HERE WHERE"

Yet, there is no failure for missing anka-template... It fails for a reason inside of the ankaRegistryPull function which is well after it tries to load the input.

https://help.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs seems to indicate that it shouldn't allow the action to run if it's missing that input.

What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Runner BugBug fix scope to the runnerbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions