How to get the last index
Can we have a new output value outputs.last that is equal to the latest value in the split array? Because steps.version.outputs.length - 1 throws a syntax error
Hi @constgen. I think you should type cast steps.version.outputs.length to integer first. Or using actions/github-script@v6 might be more appropriate for your use case.
But it seems to me so easy to implement
outputs = {
'length': str(len(results)),
+ 'last': results[len(results) - 1],
}
Or we can try absolutely different idea. Inverted indexes
outputs._-0 # last
outputs._-1 # the second from the end
outputs._-2 # the third from the end
...others
Agree that it is easy to implement. You don't even have to do it like results[len(results) - 1], just results[-1]. But I just wonder in what specific use-case this change would be useful.
My case is that I try to extract the full version 113.0.0 from branch name refs/heads/versions/113.0.0
Thanks to let me know. I'll add last output for it.