Haxe + GitHub Actions (Cross post)

Howdy all!

So I’ve been playing with github workflows for haxeui the last couple of days, and came up with a pretty decent workflow so thought i would share in case its useful for anyone else or in case anyone might like to either write, or help write a proper haxe workflow custom action… HF? :wink:

An important thing i wanted / needed in my build is the ability for commits to haxeui-core to trigger builds (github workflows) in other repositories, namely, the haxeui-backends. As it turns out this was relatively simple by having the backend repos trigger on “push” as well as “repository_dispatch”… all haxeui-core has to do now in its workflow is send a load of curl commands to these repos to trigger this dispatch:

    - uses: actions/checkout@v1
    - name: Dispatch
      run: |
        curl --fail -X POST https://api.github.com/repos/ianharrigan/GitHubActionsTest/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: Bearer ${{ secrets.GH_TOKEN }}' --data "{\"event_type\": \"test\"}"

The other fairly important thing was the custom workflow action. I needed a way to be able to install and setup haxe as simply as possible across multiple repos, i could of just copied and pasted to yaml config, but this gets out of hand pretty fast with a load of repos, so ive thrown together a custom workflow action that does this for me, then using it in my backend workflow is as simple as:

    - uses: actions/checkout@v1
    - uses: haxeui/haxeui-core/.github/actions/haxe@master
        haxe-version: 4.0.3

The action is really pretty crappy and just a “make it work” type of thing, but work it does, im using it across all my haxeui repos (well, the ones i have moved over to github workflows anyway). Another example of it is on my test repos (it uses a different source repo for the action, but its the same essentially):

name: Haxe (all versions, all platforms, all targets)

on: [push, repository_dispatch]


    runs-on: ${{ matrix.os }}

        os: [ubuntu-latest, macos-latest, windows-latest]
        haxe-version: [3.4.4, 4.0.3]
        hxml: [js.hxml, cpp.hxml]

    - uses: actions/checkout@v1
    - uses: ianharrigan/GitHubActionsTest/.github/actions/haxe@master
        haxe-version: ${{ matrix.haxe-version }}

    - name: Build app (${{ matrix.hxml }}, haxe ${{ matrix.haxe-version }}, ${{ matrix.os }})
      run: |
        haxelib install ${{ matrix.hxml }} --always
        haxe ${{ matrix.hxml }}

So that will build a js and hxcpp app on linux, osx and windows using haxe 3 and 4.

Anyways, i figured possibly this might be useful for someone, and might motivate / help someone to write a proper (maybe official?) custom haxe workflow action.

Here are some links to the workflows / actions for ref (may also be useful to someone maybe):


1 Like