-
Notifications
You must be signed in to change notification settings - Fork 40.7k
GitHub Actions
This document provides the conventions that we use to configure workflows and actions on GitHub Actions. Consistency are quite important as workflows may need to evolve over multiple generations.
Jobs are decomposed into actions that are as reusable as possible.
These are located in .gitub/actions
.
Workflows are as simple as possible and are meant to define a job that "just" chain actions together.
Each workflow is defined in .github/workflows
.
We apply the following to ensure consistency:
-
Names are title cased.
-
Descriptions are single quoted. If a single quote is required, you should double it to escape it.
-
List of attributes, are ordered alphabetically. This ensures that the location of an additional attribute is predicable, which makes diff across generations easier to read.
-
The structure of a YAML file is well-defined, see below for examples.
Each action is defined in an action.yml
located a sub-directory of .github/actions
.
If possible, additional assets such as configuration files should be located in the same sub-directory.
The basic structure of an action is as follows:
name: <short name>
description: <human readable description, single quoted>
inputs: <input attributes, oredered alphabetically>
outputs: <output attributes, ordered alphabetically>
runs:
Inputs are ordered alphabetically.
Each input has the following attributes, default
is optional.
inputs:
attribute-1:
description: <human readable description, single quoted>
required: <true/false>
default: <optional: default value, single quoted>
attribute-2:
description: <human readable description, single quoted>
required: <true/false>
Description follows the same semantic as our configuration properties.
Action attributes can only be String
.
If a boolean value is used, it unfortunately has to be quoted (e.g. 'false'
) and treated accordingly.
A step can have multiple attributes, and we can’t list them all. Here are some examples based on our own usage.
steps:
- name: <short name>
id: <optional: identifier if reference to the step is necessary>
if: <optional: step condition>
uses: <action to use>
with: <optional: list of input parameters, ordered alphabetically>
env: <optional: list of environment variables, ordered alphabetically>
The basic structure of a workflow is as follows:
name:
on:
concurrency:
permissions:
jobs:
There are more settings available, but this document focuses on our own use.
A job can have multiple attributes, and we can’t list them all. Here are some examples based on our own usage.
jobs:
<id>:
name: <name>
if: <optional: job condition>
needs: <optiona: jobs that should have completed>
runs-on:
steps: