Using bashew in GitHub Actions

GitHub Actions, used in countless CI/CD setups, are a good example of the ubiquity of bash scripting. Most of the run: lines in an Action YML document are nothing but (a sequence of) bash command lines.

I knew this could be a good match for bashew scripts-based bash scripts, but I only found some time to try that out last weekend.

TL;DR: bashew scripts are a great way to streamline your GitHub Actions

bashew in GitHub Action scripts


I got inspired by Automating screenshots using shot-scraper via Hacker News. The shot-scraper documentation describes how to set it up for using GitHub Actions to do the actual screen grabbing. I used that as a starting point and I distilled it into an efficient example project: pforret/bashew_github_action.


I created 3 sub commands in the script:

The YML code to run each of them in sequence, is super easy:

    - name: gha:before
      run: |
        ./ gha:before
    - name: gha:execute
      run: |
        ./ gha:execute
    - name: gha:after
      run: |-
        ./ gha:after

This is one of the screenshots it generates: automatic screenshot via shot-scraper


Using a bashew script to streamline your GitHub Actions is a good idea because:

Try it out

# install bashew, if necessary
basher install pforret/bashew
# add a new bashew script to your project
bashew script
# add subcommands setup/payload/wrapup, or gha:before,gha:execute,gha:after

or even easier:

# clone the example repo
git clone
# copy and .github/workflows/shots.yml to your project
# start editing the gha:before and gha:execute subcommands
    [[ -z "${RUNNER_OS:-}" ]] && IO:die "Only run inside a Github Action"
    Os:require pip python3
    pip install shot-scraper
    shot-scraper install
💬 bash 🏷 bashew 🏷 github 🏷 action 🏷 runner 🏷 ci