Git Hub Actions

by

Simon Hofmann

-

2019-02-20

Overview

  • Intro
  • How do GitHub Actions work?
  • What are GitHub Actions Good For?
  • act
  • Resources

Intro

GitHub Actions

GitHub Actions

GitHub Actions

  • Allow to implement custom logic on GitHub
  • Fully integrated, no external app required
  • Graphical editor and / or text based editing
  • Veeeeery flexible!
  • Still invite only beta 😭

Hooray!

I got invited!

How do GitHub Actions work?

triggers

  • Actions are triggered by GitHub events
    • create
    • issue
    • pull_request
    • push
    • and more...

workflow

  • Workflows map events to actions
  • Sample:
    							
    								workflow "Build and deploy to gh-pages" {
    									on = "push"
    									resolves = [
    										"Deploy if on master",
    										"Test",
    										"Production build && Deploy",
    									]
    								}
    							
    						

resolves

  • When a workflow executes, one or more actions may be resolved
  • Resolving means to execute every (transitive) dependency of an action
  • If one action fails, no subsequent actions will be executed

actions

  • Working parts of a workflow
  • Running in Docker containers
  • Sample:
    							
    								action "Production build && Deploy" {
    									uses = "docker://node:10"
    									needs = ["Deploy if on master"]
    									secrets = [
    										"DEPLOY_USER",
    										"GITHUB_TOKEN",
    									]
    									runs = "npm run deploy"
    								}
    							
    						

uses

  • Specifies what to actually run
  • Multiple sources supported
    • ./path: Specifies the path to a Dockerfile in current repo
    • owner/repo/path@ref: Reference another GitHub repo containing an action
    • docker://image: References a Docker image

needs

  • Specifies dependencies
  • Chains actions to form a "pipeline"

runs

  • Specifies which command to run in the Docker container

args

  • Specifies which parameters to append to the "runs" command

env

  • Allows to configure container environment variables
  • "ENV"

secrets

  • Allows to inject secrets as environment variables
  • Created via Web UI
  • Stored encrypted, no plain-text passwords

What are GitHub Actions good for?

CI / CD

  • Build and deploy to GitHub Pages
  • Deploy to any (major) cloud provider
    • AWS, Azure, netlify, etc.
  • Publish artifacts
    • npm, Maven Central etc.

Workflow automation

  • Cleanup branches
  • Apply labels
  • Auto rebase
  • Auto PR
  • etc ...

Notifications

  • Slack
  • Twitter
  • Email
  • etc ...

act

act

  • Run your GitHub Actions locally!
    • Run full workflow
    • Or just single steps

act

  • Experiment locally!
    • Run default event (push)
    • Or a specific one

act

act for GitHub Actions

Resources

That's it!

Thank's for your attention!

Questions?

Or feedback?