Validate required inputs are set before invoking an action
See original GitHub issueDescribe 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?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:48
- Comments:20
Top Results From Across the Web
Why are required inputs to GitHub Actions not enforced?
1 Answer. Currently GitHub does not check if required input has been passed. This is being tracked in this issue. However, you can...
Read more >Validating Input | Web Accessibility Initiative (WAI)
Validating required input Forms frequently include required input that needs to be clearly identified using labels. Also, the required attribute can be...
Read more >How to Validate Forms in React – A Step-By-Step Tutorial ...
We will implement input validation using react-hook-form, which will ensure that the data entered by users is valid before it is submitted.
Read more >Input Validation - Adaptive Cards
Inputs will be validated when the user clicks on an Action.Submit action in the card. Those inputs which will be validated and submitted...
Read more >Apps - Use Required Input Validation
You can use required input validation to notify the user in runtime that input to a control is mandatory by setting the Required...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So what’s the point of
required
? 🤔I just ran into the same issue. Have to say it’s quite unexpected to mark something as required and then finding out it blows up silently. Especially since toolkit is the official GitHub toolkit for actions.
I think this would make a lot of sense 😃