Github Actions

Understanding GitHub Actions

Overview

  • CI/CD platforms

  • Allows you to automate your build, test, and deployment pipeline

The components of Github Actions

  • Workflows ⊃ Events ⊃ Jobs

  • Can configure a workflow to be triggered

    • A pull request being opened

    • An issue being created

  • Job has one or more steps(script or action)

    • Job will run inside VM, container

Workflows

  • Workflows == Configurable automated process

  • Written in yaml

  • Manually or defined schedule

  • Defined in the .github/workflows

    • Can have multiple workflows

      • e.g.) There are A, B, C workflows

        • A - Build and test

        • B - Deploy your application

        • C - Adds label

  • Can reuse with reference

Events

  • Activity that triggers a workflow run

  • Activity examples

    • Pull request

    • Opens an issue

    • Pushes a commit to a repository

    • Schedule(by posting REST API, or manually)

Jobs

  • Set of steps in a workflow that execute on the same runner

    • Each step = shell script

    • Can share data, step <--> step

    • Can configure job's dpendencies with other jobs

Actions

  • Performs repeated task

  • Actions can

    • Pull git repository

    • Set up toolchain

    • Set up authentication to your cloud provider

Runners

  • Server(virtual machine)

  • Each runner can run single job at a time

  • Can host your own runners

Create an example workflow

Finding and customizing actions

Overview

Actions are defined in

  • The same repository as your workflow file

  • Any public repository

  • A published Docker container image on Docker Hub

You can keep your actions up to date with Dependabot.

Adding an action to your workflow

Adding an action from the same repository

Adding an action from a different repository

Referencing a container on Docker Hub

Using release management for your custom actions

link

Using inputs and outputs with an action

Essential features of GitHub Actions

Overview

Customization techniques

  • Using variables

  • Running scripts

  • Sharing data and artifacts between jobs

Using variables in your workflows

Adding scripts to your workflow

Exmaple 1

Exmaple 2

Sharing data between jobs

Can share job generated files as artifacts in Github. All actions and workflows called within a run have write access to that run's artifacts.

Artifacts

  • Created when you build and test your code.

  • Binary or package files

  • test results

  • screenshots,

  • log files

Create a file, upload it as an artifact

Download artifact

Last updated