Workflows are the heart of your development process. They are custom automated processes that get setup right alongside the code in your repositories. Workflows can be used for many forms of automation. Tasks within a workflow range from building code and automated testing or other workflow automation processes like thanking new project contributors and reminding developers to review a pull request.
Thinking of a workflow as an interface between developers and task automation is a good place to start. It's here in the workflow that units of work, and how that work will be completed, get defined. This file also provides a location for developers to pass parameters and other necessary information to the individual actions that are being used to perform the work.
Workflows are also used to define which events will trigger them and what environment variables will exist throughout the workflow. Lastly, workflows hold the definition of the jobs you wish to run when the workflow is triggered.
Workflow files aren't without their limitations. Keeping this list in mind will help your adoption of using workflows be a bit smoother.
- People with write or admin permissions to a repository can create, edit, or view workflows.
- You must store workflows in the
.github/workflows
directory in the root of your repository. - You can configure a workflow to start when a GitHub event occurs, on a schedule, or from an external event.
- You need to configure workflows using YAML syntax.
- More than one workflow can exist within a repository.
name: Greet Everyone
# This workflow is triggered on pushes to the repository.
on: [push]
jobs:
greet-users:
# Job name is Greeting
name: Greeting
# This job runs on Linux
runs-on: ubuntu-latest
steps:
# This step uses GitHub's hello-world-javascript-action: https://github.com/actions/hello-world-javascript-action
- name: Hello world
uses: actions/hello-world-javascript-action@v1
with:
who-to-greet: "Mona the Octocat"
id: hello
# This step prints an output (time) from the previous step's action.
- name: Echo the greeting's time
run: echo 'The time was ${{ steps.hello.outputs.time }}.'