Hacker News new | ask | show | jobs
by satyadeepk 2471 days ago
GitHub actions are pretty easy to get started even for CI beginners. Only few things I feel lacking, 1. Environment variables can only be defined on steps, they can't be defined at a job level. So the same code has to be repeated in each step. 2. There's no way to manually trigger a job.
3 comments

> 1. Environment variables can only be defined on steps, they can't be defined at a job level

Actually you can define global environment variables with an extra step... here is how I do it. I was quite frustrated until I worked this out!

      - name: Set environment variables
        shell: bash
        run: |
          echo '::set-env name=GOPATH::${{ runner.workspace }}'
          echo '::add-path::${{ runner.workspace }}/bin'
          echo '::set-env name=GO111MODULE::${{ matrix.modules }}'
          echo '::set-env name=GOTAGS::${{ matrix.gotags }}'
          echo '::set-env name=BUILD_FLAGS::${{ matrix.build_flags }}'
That actually works! Thank you.
> Environment variables can only be defined on steps, they can't be defined at a job level. So the same code has to be repeated in each step.

I haven't been able to play with Actions to confirm what I'm about to say, but if they use a fully compliant YAML parser you can use YAML anchors to do "copy-paste" without the copy paste; I think GitLab actually fully recommended such an approach before they supported `extends:` in their pipeline document

I'm on my phone or I would link to the YAML spec and GitLab examples in their docs for the gory details

Looks like YAML anchors and aliases are not currently supported. https://github.community/t5/GitHub-Actions/Support-for-YAML-...
Regarding point #2, have you checked external triggers [0] in the documentation? When starting off, it was easier for me to just push an empty/pointless commit to get the whole process running, but setting up the webhook should also be easy.

[0] https://help.github.com/en/articles/events-that-trigger-work...