Github Actions
Github Actions makes it easy to test, build, and deploy your code into the cloud.
Workflow
A workflow is a configurable automated process that will run one or more jobs. Workflows are defined by a YAML file checked in to your repository and will run when triggered by an event in your repository, or they can be triggered manually, or at a defined schedule.
Events
Events are specific activity that triggers a workflow run. For example, activity such as pushing code to a repository or opening a pull request. You can configure a workflow to run when specific activity on GitHub happens. Common events are push, pull_request, schedule, etc.
Example: push event. Runs your workflow when you push a commit or tag, or when you create a repository from a template.
1 | on: |
Jobs
A workflow run is made up of one or more jobs, which run in parallel by default.
Use jobs.<job_id>
to give your job a unique identifier. To run jobs sequentially, you can define dependencies on other jobs using the jobs.<job_id>.needs
keyword.
Dependant jobs will run after the jobs they depend on have completed successfully. If a job fails, the dependant jobs will not run.
1 | jobs: |
Runners
A runner is a server that runs your jobs. You can use a GitHub-hosted runner, or you can host your own runner. Each job in a workflow run runs on a fresh instance of the runner.
1 | runs-on: ubuntu-latest |
Steps
Each job in a workflow run is made up of one or more steps. Steps are a sequence of tasks that execute commands. Steps can run commands, run setup tasks, or run an action in your repository, a public repository, or an action published in a Docker registry.
Example
In your repository on GitHub, create a workflow file called github-actions-demo.yml in the .github/workflows directory.
github-actions-demo.yml
1 | name: CI |
Commit the file to the main branch of your repository. This will trigger the workflow to run on the next push to the repository.
References: