chapter four

4 GitHub Actions

 

This chapter covers the following topics:

  • Types of actions
  • Authoring actions
  • Hands-on: my first Docker container action
  • Sharing actions
  • Advanced action development

Now that we have explored the YAML and workflow syntax in detail, this chapter will dive into the core building block of GitHub Actions – the reusable and sharable actions themselves that give the product its name.

The chapter will cover the different types of actions and some tips to get started writing your first actions. We will cover this in detail in a hands-on lab, where you can follow along step by step. Additionally, the chapter will cover sharing actions in the marketplace and internally, and some advanced topics for action authors.

4.1 Types of Actions

There are three different types of actions:

  • Docker container actions
  • JavaScript actions
  • Composite actions

Docker container Actions only run on Linux whereas JavaScript and composite Actions can be used on any platforms.

All actions have in common, that they are defined by a file action.yml (or action.yaml) that contains the metadata for the action. This file cannot be named differently, meaning a action must reside in its own repository or folder. The run section in the action.yml file defines what type of action it is.

4.1.1 Docker container actions

4.1.2 JavaScript actions

4.1.3 Composite actions

4.2 Authoring Actions

4.2.1 Getting started

4.2.2 Storing actions in GitHub

4.2.3 Compatibility with GitHub Enterprise Server

4.2.4 Release management

4.3 Hands-on: a docker container action in action

4.3.1 Use the template to create a new repository

4.3.2 Create the Dockerfile for the action

4.3.3 Create the action.yml file

4.3.4 Create the entrypoint.sh script

4.3.5 Create a workflow to test the container

4.4 Sharing Actions

4.4.1 Sharing actions in your organization

4.4.2 Sharing actions publicly

4.5 Advanced Action development

4.6 Best practices

4.7 Conclusion

4.8 Summary