A First Look at GitHub Actions
Published:
GitHub Actions can be used to automate, customize, and execute software development workflows from within a GitHub repository.
Outline
- Introduction
- Create an Action
- Complete GitHub Action
- Push your project to a GitHub repository
- Create a new blank repository
- Discover Related Articles
All of this project’s code can be found in the First Look monorepo on my GitHub.
Introduction
GitHub Actions can be used to automate, customize, and execute software development workflows from within a GitHub repository. You can discover, create, and share actions to perform CI/CD jobs and combine actions in a customized workflow.
Create an Action
We will create a boilerplate workflow to help you get started with Actions.
on
controls when the workflow will run. push
and pull_request
events trigger the workflow but only for the main branch. workflow_dispatch
allows you to run this workflow manually from the Actions tab.
A workflow run is made up of one or more jobs
that can run sequentially or in parallel. Our workflow contains a single job called build
that is running on ubuntu-latest
.
steps
represent a sequence of tasks that will be executed as part of the job. uses
checks-out your repository under $GITHUB_WORKSPACE
, so your job can access it. run
will run a single command (echo "Hello from GitHub Actions"
) which will print Hello from GitHub Actions
using the runner’s shell.
The action will then run a multi-line script to print a series of messages containing common environment variables such as the repository name and job status.
Complete GitHub Action
Push your project to a GitHub repository
Initialize the repository, add all changes to the staging area, and commit all staged changes.
Create a new blank repository
You can create a blank repository by visiting repo.new or using the gh repo create
command with the GitHub CLI. Enter the following command to create a new repository, set the remote name from the current directory, and push the project to the newly created repository.
If you created a repository from the GitHub website instead of the CLI then you will need to set the remote and push the project with the following commands.
Go to the actions tab on your GitHub repository to see your action.
Click your action to see the specific workflow.
Click “build” to see more details.
Click “Set up job” for more info.
Click “Run actions/checkout@v2” for more info.