Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lession learned - How to build a GitHub Action

Lession learned - How to build a GitHub Action

Given at a company internal thundertalk.

Me and a few colleagues participated at the GitHub Actions Hackathon 2020.
We didn't know how to build a GitHub Action.
This slides gives you a roughly overview how you can build a GitHub Action by yourself.

Stefan M.

April 30, 2020
Tweet

More Decks by Stefan M.

Other Decks in Technology

Transcript

  1. About GitHub Actions (consumer side) • CI/CD • 4 runners

    • macOS, Windows, Linux and self hosted • Run on real machines • There is pre installed software • There are environment variables • There is also a ready-to-use GitHub Token • Full acces to the GitHub API via the Context (and more!)
  2. Build an Action • “Native” with JavaScript or Docker container

    • JS is • faster • runs on all runners • not that flexible than a Docker container • Docker is • slower • runs only on Linux runners (shouldn’t be a problem, right?) • 100 percent flexible
  3. Build an Action – Where? • Own repository or inside

    your project repository in .github/actions/[nameOfAction]/ • Own repository is reuseable
  4. Build an Action – Version! • commit -> author/repo-name@745bc508 •

    tag -> author/[email protected] • branch -> author/repo-name@master • Actions in your project repository don’t require this of course
  5. Build a Docker Action • Createa a Dockerfile • Requires

    a ENTRYPOINT • Create a Action Metadata file • (More about this later) • Write the Actions code in the entrypoint
  6. Build a JavaScript Action • Create a Action Metadata file

    • (More about this later) • Install Action toolskits • npm install @actions/core • npm install @actions/github • Write the Action code in a file called index.js
  7. The Action Metadata file - Output • The (maybe) output

    of the Action • An Action assembles an Android Project. The output is the apk/aab. • The output can be used with the expression syntax
  8. The Action Metadata file - Run • Run describes how

    the Action should be run. Docker or JavaScript • Docker: JS: Dockerfile or any public Docker image