nobe4 / Posts / Bash over Node _

 |  Work Tech  |  Disclaimer

A GitHub Action at work goes from a Node.js action to a composite action running a single bash script.

The scenario is ideal: the action only does an HTTP request, JSON parsing, and some conditions.

Before and after ΒΆ

Before (Node)After (Bash)
Files~151
Size137M36K
Runtimenode20composite + bash
Dependencies19 npm packagescurl, jq, openssl
Build stepncc bundle + commit dist/none
Lines of logic2000~179
CI workflowslint, format, test, pkgbash -n
Supply chain riskmedium (npm)near zero

Before file tree:

.babelrc
.eslintignore
.eslintrc.json
.prettierignore
.prettierrc.json
.node-version
action.yml
package.json          (7 deps, 12 devDeps)
package-lock.json
node_modules/         (hundreds of packages)
dist/index.js         (bundled with ncc)
src/main.js
src/functions/service.js

After file tree:

action.sh
action.yml

Benefits ΒΆ

Shortcomings ΒΆ

Bash does not fit when:

Conclusion ΒΆ

The best code is code you don’t maintain. Bash gives this action fewer files, fewer deps, fewer failure modes, and the same result.

If everything you need is already in the default Unix toolbox, use it.