# Haxe + GitHub Workflows / Actions

**URL:** https://community.haxe.org/t/haxe-github-workflows-actions/2177
**Category:** Haxe
**Created:** [December 13, 2019, 11:48am UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177 "2019-12-13T11:48:18Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [December 13, 2019, 11:48am UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/1 "2019-12-13T11:48:19Z")

</div>

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? 😉

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:

```haxe
    steps:
    - 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:

```haxe
    steps:
    - uses: actions/checkout@v1
    - uses: haxeui/haxeui-core/.github/actions/haxe@master
      with:
        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):

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

on: [push, repository_dispatch]

jobs:
  build:

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

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

    steps:
    - uses: actions/checkout@v1
    - uses: ianharrigan/GitHubActionsTest/.github/actions/haxe@master
      with:
        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.

 ![image](https://community.haxe.org/uploads/default/original/2X/4/4450331b5321d617eeccd43c5906f4a7c03dfb1b.png)

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):

- custom github action - [haxeui-core/.github/actions/haxe at master · haxeui/haxeui-core · GitHub](https://github.com/haxeui/haxeui-core/tree/master/.github/actions/haxe)
- haxeui-core dispatcher - [haxeui-core/build.yml at master · haxeui/haxeui-core · GitHub](https://github.com/haxeui/haxeui-core/blob/master/.github/workflows/build.yml)
- haxeui-html workflow - [haxeui-html5/build.yml at master · haxeui/haxeui-html5 · GitHub](https://github.com/haxeui/haxeui-html5/blob/master/.github/workflows/build.yml)
- haxeui-openfl workflows - [haxeui-openfl/.github/workflows at master · haxeui/haxeui-openfl · GitHub](https://github.com/haxeui/haxeui-openfl/tree/master/.github/workflows)
- haxeui-kha workflows - [haxeui-kha/.github/workflows at master · haxeui/haxeui-kha · GitHub](https://github.com/haxeui/haxeui-kha/tree/master/.github/workflows)
- haxeui-hxwidgets workflows - [haxeui-hxwidgets/.github/workflows at master · haxeui/haxeui-hxwidgets · GitHub](https://github.com/haxeui/haxeui-hxwidgets/tree/master/.github/workflows)
- hxWidgets workflows - [hxWidgets/.github/workflows at master · haxeui/hxWidgets · GitHub](https://github.com/haxeui/hxWidgets/tree/master/.github/workflows)

Cheers,  
Ian

---

<div class="post-metadata">

### Author: ![cedx](https://community.haxe.org/user_avatar/community.haxe.org/cedx/32/2377_2.png) [@cedx](https://community.haxe.org/u/cedx)
#### Post date: [July 7, 2020, 8:17pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/2 "2020-07-07T20:17:05Z")

</div>

Note that there is now a dedicated action to setup Haxe:

> **[Setup Haxe environment - GitHub Marketplace](https://github.com/marketplace/actions/setup-haxe-environment)**
>
> Setup a Haxe environment and add it to the PATH

---

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [July 8, 2020, 9:30am UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/3 "2020-07-08T09:30:17Z")

</div>

Nice, good to know, ill have to take it for a spin, would be nice to retire the extremely messy versions i came up with - had a quick look of the code and looks ALOT cleaner, so that bodes well 🙂

Thanks for the info!

Ian

---

<div class="post-metadata">

### Author: ![joshtynjala](https://community.haxe.org/user_avatar/community.haxe.org/joshtynjala/32/792_2.png) [@joshtynjala](https://community.haxe.org/u/joshtynjala)
#### Post date: [July 10, 2020, 12:30am UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/4 "2020-07-10T00:30:51Z")

</div>

Thanks for sharing! I’ve been using Ian’s action to build Lime, OpenFL, and Feathers UI. I’ll be sure to give yours a try too.

---

<div class="post-metadata">

### Author: ![endel](https://community.haxe.org/user_avatar/community.haxe.org/endel/32/508_2.png) [@endel](https://community.haxe.org/u/endel)
#### Post date: [October 4, 2020, 1:31pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/5 "2020-10-04T13:31:11Z")

</div>

Thanks a lot for this @cedx. Your action allowed me to create mine 🙂

I’ve just created a workflow to automatically submit a package to haxelib whenever the version changes: [GitHub - endel/haxelib-publish-github-actions-test: Testing GitHub Actions to publish a Haxe package to the haxelib registry.](https://github.com/endel/haxelib-publish-github-actions-test)

---

<div class="post-metadata">

### Author: ![ianharrigan](https://community.haxe.org/user_avatar/community.haxe.org/ianharrigan/32/52_2.png) [@ianharrigan](https://community.haxe.org/u/ianharrigan)
#### Post date: [October 4, 2020, 1:44pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/6 "2020-10-04T13:44:47Z")

</div>

Thanks for reminding me, keep meaning to move all my repos over the @cedx’s versions as they look like a 100% improvement over the thrown together versions i came up with!

Cheers,  
Ian

---

<div class="post-metadata">

### Author: ![cedx](https://community.haxe.org/user_avatar/community.haxe.org/cedx/32/2377_2.png) [@cedx](https://community.haxe.org/u/cedx)
#### Post date: [October 11, 2020, 2:42pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/7 "2020-10-11T14:42:31Z")

</div>

> Thanks a lot for this @cedx. Your action allowed me to create mine.

I’m not the author of this action. We should all thank **KrdLab** ([krdlab (Sho Kuroda) · GitHub](https://github.com/krdlab)).

---

<div class="post-metadata">

### Author: ![cedx](https://community.haxe.org/user_avatar/community.haxe.org/cedx/32/2377_2.png) [@cedx](https://community.haxe.org/u/cedx)
#### Post date: [December 9, 2020, 11:11am UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/8 "2020-12-09T11:11:25Z")

</div>

Running tests with different targets is quite easy because it exists a dedicated action to setup most of them:

- Haxe and Neko: [Setup Haxe environment · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-haxe-environment)
- C#: [Setup .NET Core SDK · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-net-core-sdk)
- Java: [Setup Java JDK · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-java-jdk)
- Node.js: [Setup Node.js environment · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-node-js-environment)
- PHP: [Setup PHP Action · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-php-action)
- Python: [Setup Python · Actions · GitHub Marketplace · GitHub](https://github.com/marketplace/actions/setup-python)

But I couldn’t find anything for [HashLink](https://hashlink.haxe.org). It turns out that it’s finally very easy to setup HashLink with a workflow running on the Windows platform (only! As there is currently no Linux/macOS build on the HashLink repository):

```haxe
jobs:
  hashlink:
    runs-on: windows-latest
    steps:
      - name: Fetch sources
        uses: actions/checkout@v2
      - name: Set up Haxe
        uses: krdlab/setup-haxe@v1
        with:
          haxe-version: 4.1.4
      - name: Set up HashLink
        run: |
          Invoke-WebRequest https://github.com/HaxeFoundation/hashlink/releases/download/1.11/hl-1.11.0-win.zip -OutFile hashlink.zip
          Expand-Archive hashlink.zip
          Add-Content $Env:GITHUB_PATH (Resolve-Path hashlink/hl-1.11.0-win) -NoNewline
      - name: Check environment
        run: |
          haxe --version
          hl --version
      - name: Install dependencies
        run: haxelib install all --always
      - name: Run tests
        run: haxe hashlink.hxml

```

Where the `hashlink.hxml` file is similar to:

```haxe
--class-path src
--class-path test
--hl tests.hl
--library tink_unittest
--main TestAll
--cmd hl tests.hl

```

---

<div class="post-metadata">

### Author: ![cedx](https://community.haxe.org/user_avatar/community.haxe.org/cedx/32/2377_2.png) [@cedx](https://community.haxe.org/u/cedx)
#### Post date: [July 24, 2021, 4:37pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/10 "2021-07-24T16:37:35Z")

</div>

There’s now a dedicated action for HashLink:  
[Setup Hashlink VM](https://github.com/marketplace/actions/setup-hashlink-vm)

Thanks @PXshadow for the inspiration!

---

<div class="post-metadata">

### Author: ![Hersir](https://community.haxe.org/user_avatar/community.haxe.org/hersir/32/151_2.png) [@Hersir](https://community.haxe.org/u/Hersir)
#### Post date: [August 5, 2021, 7:30pm UTC](https://community.haxe.org/t/haxe-github-workflows-actions/2177/11 "2021-08-05T19:30:03Z")

</div>

@endel would it be possible to create github action for haxelib publish ?
