Fork me on GitHub
#babashka
<
2021-11-19
>
mmz13:11:57

I'm looking for a (preferably) simple example github action where (1) babashka generates a html page in the action with code from the master branch and (2) that generated html page is published to the gh-pages branch. I have it working locally, but apparently I'm missing some docker or github action magic.

borkdude13:11:19

So I'm using a so called orphan branch

borkdude13:11:38

I'm not exactly sure at which step you are stuck. Perhaps you can reduce the problem statement to a smaller scope.

mmz13:11:07

Thanks, I'll try: On my machine (where babashka and git are installed) I can run my html-generating script on the master branch which will publish the generated html to a publish folder. Pushing to gh-pages from my local machine works with worktree (and with git subtree and by simply checking out the gh-branch merging with master and pointing the gh-pages root folder to the publish directory). So far so good. But I can't seem to find a proper (combination of) docker container(s) that have babashka installed and the correct git stuff installed or the correct package manager to properly install babashka . Feel like I'm yak-shaving, hence my question: can someone show me a github action file that already does this stuff so I can see where my assumptions are broken.

borkdude14:11:10

You can use the installer script in any docker container:

curl -s  -o install.sh
sudo bash install.sh
rm install.sh

mmz14:11:28

That tip combined with a couple of things I tried earlier today worked for me:

name: Run Script

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    name: Run script
    runs-on: [self-hosted, research]
    container: bitnami/git:2.34.0

    steps:
      - name: Checkout
        uses: actions/[email protected]

      - name: install babashka
        run: |
          curl -s  -o install.sh
          bash install.sh --version 0.6.5

      - name: Generate page(s)
        run: bb your-html-creating-babashka-script-here.clj

      - name: Install rsync # needed for the publish action 
        run: |
          apt-get update
          apt-get install -y rsync

      - name: Publish
        uses: JamesIves/[email protected]
        with:
          branch: gh-pages
          folder: publish
          git-config-name: Github Actions
          git-config-email: 

mmz14:11:43

Thank you ๐Ÿ™:skin-tone-3:

borkdude14:11:10

Is this Github actions?

borkdude14:11:30

Nice. You can also use https://github.com/turtlequeue/setup-babashka for setting up bb in those

borkdude14:11:42

Of course you don't have to

mmz14:11:43

There always seems to be something missing ... git, a specific add-on git command, a package manager, curl, etc. This setup works. ๐Ÿ˜… ๐Ÿคž:skin-tone-3:

๐Ÿ‘ 1
borkdude14:11:33

That thing isn't a specific image, it's just an action which installs babashka

awb9913:11:00

Just want to provide some feedback on babashka tasks: Its the best tool I found in a long time. Prior to that I only remember rclone. With rclone, I have a simple command line interface which allows me to move files between cloud providers. So what is so cool about babashka tasks: well, I have A LOT of bash files. I have a repo for my linux install tasks. In there are 30 bash scripts, for each distro I use (manjaro/debian/redhat/guix). So 120 scripts. Now I have no idea which scripts I have. Many times I created a new bash file just to install an app with a specific configuration. This is because bash scripting sucks. With babashka tasks, I have a task list. So I dont need to do ls to find my bash scripts. Since babashka is clojure, I can easily do some checks on the parameters that I pass to bb tasks, to see if this is valid. If I dont have a custom config for a app, I cannot install that profile. Babashka tasks is a tool that gives me 10x benefit. I can combine multiple things, that otherwise with bash I could not. I could of course, but my bash scripts would suck, due to obscure bash syntax. It is absolutely amazing how many clojure libraries work in babashka. So I really dont need two different apis/interfaces. And of course the thing to run tasks in parallel or sequentially. I wonder if there are some cli tools that generate nice menus. It would be really intersting to say auto generate a cli dialog to pick an option. I am sure this tools exist, and that they can be integrated with babashka. A sort of parameter picker for bb tasks. Anyhow. Its an amazinig tool. Thank you so much!

โค๏ธ 1
๐Ÿš€ 2
awb9913:11:09

In case someone uses GUIX. GUIX makes sense, as it is an operating system that can be configured with guile, a scheme dialect. There is no package for babashka , so I made one: https://github.com/pink-gorilla/gorilla-guix-chan

awb9913:11:44

This is the package for babashka.

awb9913:11:13

To my shame, I am doing a binary install only. I would like to do a full source code build of babashka on another day. ๐Ÿ™‚ When that happens, I guess guix will include babashka to their main repo list.

borkdude14:11:55

There are also packages on nix for babashka, perhaps it's a similar strategy

awb9914:11:03

I am sure it is.

awb9914:11:05

But for guix, they define g-expressions. This is a concept I dont yet understand. It is like a macro, but on a package manager level. And there is no way to test this macros. So I - at the moment - am not able to do that.

awb9914:11:13

The binary file install was all I managed to do.

awb9914:11:18

And this took me a week ๐Ÿ™‚

โค๏ธ 1
๐Ÿ™Œ 1
awb9918:11:55

Question: does the babashak shell command have a parameter to set certain environment variables?

awb9918:11:11

so to set an environment variable only for the shell command that runs ?

borkdude18:11:06

:extra-env adds to the environment that already exists in bb, :env replaces it

awb9918:11:19

Thanks! Sorry for asking stupid questions. I tried to find it in the bababshka book.. but could not find it...

borkdude18:11:09

I will add it to the book. It says this in the docs: > Other supported options are similar to those ofย `babashka.process/process`.

awb9918:11:17

Is there any function that adds to a path?

awb9918:11:56

Like export XXX=$XXX:blah

borkdude18:11:40

No, you cannot do that in a JVM, the environment is immutable

awb9918:11:51

I will write it with System/getEnv

borkdude18:11:51

You can however launch a new bb with env vars: (shell {:extra-env {"FOO" "BAR"} "bb some-task")

awb9918:11:53

(defn guix [command & args] (println "running guix " command) (apply shell "guix" command args)) (defn extra-path-env [var extra] (let [current (System/getenv var) appended (str current ":" extra)] (println "adding extra path: " appended) {:extra-env (assoc {} var appended)})) (defn guix-extra [command & args] (apply shell (extra-path-env "GUILE_LOAD_PATH" "./scm") "guix" command args))

๐Ÿ‘ 1
awb9918:11:00

exra-path-env

awb9918:11:03

love it ๐Ÿ™‚