The Complete GitHub Actions & Workflows Guide
4.6 (111 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
786 students enrolled

The Complete GitHub Actions & Workflows Guide

Automate Code Testing, Deployment & Versioning using CI/CD Workflows. Create & Publish GitHub Actions to the Marketplace
4.6 (111 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
786 students enrolled
Created by Ali Alaa
Last updated 6/2020
Current price: $83.99 Original price: $119.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 8 hours on-demand video
  • 4 articles
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Learn about writing serialized data in the YAML format
  • Discover conceptually what workflows and GitHub actions are
  • Learn what terms like action, step, job, event, workflow, etc.. mean
  • Discover everything you can do in a github workflow (events, schedules, filtering, environment variables, context, encryption, matrix and more)
  • Learn how docker can be used in a github workflow
  • Create a real-life CI/CD workflow for code testing, formatting, versioning and more
  • Learn how to use semantic versioning to automatically version your code in your workflow
  • Upload code testing coverage reports in your workflows using codecov
  • Use caching in workflows for faster performace
  • Learn about uploading artifacts in workflows
  • Learn about how to create your own custom GitHub Actions using Javascript or Docker
  • Create an action for opening GitHub issues using JavaScript
  • Create an action for sending slack messages using PHP
  • Learn how to publish GitHub actions in the GitHub marketplace.
Course content
Expand all 61 lectures 07:58:58
+ Introduction
8 lectures 01:08:05
Course Source Code

Let's before writing any code take a look at some theoretical information. We will learn about what events, workflows, jobs, steps, actions, virtual environments and runners in github actions are.

Preview 09:36

Github workflows are written in a serialization language called YAML. In this lecture we will have a look on how to use this format and what are the different syntaxes that we can use with it.

A Brief Introduction to Writing in YAML Format

Let's finally create our first workflow and do the simplest thing which can be done in a workflow which is running shell commands. We will also take a look at the actions tab user interface on github which is used to view the worfklow result. This tab will contain all workflows, jobs, steps and logs and it can be very useful when debugging errors that made a job fail.

Let's Create Our First Workflow

When running shell commands in github actions, we can choose between different kinds of shells like bash, powershell, python and more. Let's learn how and when to use these shells in this lecture.

Using Different Shells for Each Step

Running shell commands in our jobs can be very useful. But on the other hand using actions can do a lot more stuff in very few lines of code. Let's see what actions are and use our first simple action in this lecture.

Preview 10:23

A very common thing that you might need to do when running a workflow on a virtual machine; is using the files in your repository to do something. These can be things like running tests or deploying an application. By default your repository won't get cloned on the virtual machine when you run a workflow. However you can easily do that using the checkout action.

The Checkout Action
Quick Note!
+ Events, Schedules, External Events & Filters that can Trigger a Workflow Run
4 lectures 44:28

In this lecture we will learn about different github events that can trigger a workflow to run like push, pull_request and issues. We will also see what are activity types and how to use them.

Triggering a Workflow with Github Events & Activity Types

In github actions, we can run workflows at certain scheduled times using the crontab schedule expression. Let's take a look at that in this lecture.

Setting a Schedule to Trigger Workflows

Play around with and then come back here and try to complete this quiz without using the tool.

Test Your Cron Expression Knowledge
4 questions

In this lecture we will take a look at the final way which can trigger workflow runs. Using this way we can manually trigger workflows outside of github normal events like push, pull_request, etc... And in order to do that we will use an event called repository_dispatch that can be triggered manually using a POST request.

Preview 10:51

We can choose to run our workflows only if we push to certain branches, tags. We can also exclude branches and tags. And we can also filter by certain paths or file types. Let's see about that in this lecture.

Filtering Workflows by Branches, Tags & Paths

Now it's time to make sure we correctly understand filtering and patterns. Take a look at this cheat sheet before/while solving this quiz:

Workflows Filtering Quiz!
7 questions
+ Environment Variables, Encryption, Expressions & Context
7 lectures 57:56

In this lecture we will learn how to set our own environment variables. And also how to scope environment variable to a workflow, a job or a step. We will also see what default environment variables does github provide us.

Default & Custom Environment Variables

Sometimes we might need to use some sensitive information in our workflow. For example, we might need to call some third-party API which required a secret to authenticate. In this case we should encrypt our key in order not to be exposed in the workflow file.

Encrypting Environment Variables

Using the GITHUB_TOKEN secret we can do some interesting stuff in our workflow. For instance we can call Github's REST API to perform some operation in our repository.

Using the GITHUB_TOKEN Secret for Authentication

Sometimes simple secrets are not enough. In some cases we might need to encrypt large files and decrypt and use them in our workflow. This is possible in github using the gpg cli tool.

Encrypting & Decrypting Files

In Github actions we can write expressions, these expressions can be literals, functions, operations or contexts. In this lecture we will focus on contexts which are objects that contain valuable information about our workflow run.

Preview 06:14

Similar to contexts, Github also provides us with some functions that we can use in our expressions. Let's take a look at these in the next lecture.

Using Functions in Expressions

In addition to the utility functions that we saw in the last lecture, Github also provides us with additional functions that can help us check the status of our job.

The If key & Job Status Check Functions
+ Using Strategy, Matrix & Docker Containers in Jobs
10 lectures 01:00:25

In this quick lecture we will just take a look at a couple of options that you should know about in your workflows. And these are: continue-on-error and timeout-minutes.

Continue on Error & Timeout Minutes

Before creating our first matrix, let's see how we can use the setup-node action in order to change the node version in our environment.

Using the setup-node Action

Let's know see how to use the strategy option in order to create multiple runs of the same job but using different environments.

Creating a Matrix for Running a Job with Different Environments

In matrices we can exclude some configurations from running or we can add extra information to a specific configuration.

Including & Excluding Matrix Configurations

Instead of running our jobs directly on our vitual machines, we can run them in a docker container. Let's see how can we specify a docker container in our jobs.

Using Docker Containers in Jobs

In some cases we might need to use docker-compose to run an application that needs multiple services. Let's take a look on a simple example of that so that we can try to run it on our workflow in the next lecture.

An Overview of a Simple Dockerized NodeJS API

Let's now see how can we run the application that we ran using docker in the last lecture but this time inside of our workflow.

Running Multiple Docker Services in our Workflows

In addition to using docker containers in our whole jobs, we can also specify different containers to run inside of each of our steps.

Running Docker Containers in Individual Steps

In addition to using executables that we have on our system, we can also write our own scripts and run them as entrypoints to a docker container in our steps.

Creating our Own Executable File and Running it in our Steps

Let's try a useful example of using docker containers in steps. And that is sending a slack message.

Preview 05:53
+ Creating a CI/CD Workflow to Automate Testing and Deployment
21 lectures 02:21:32

Let's Create a simple application that our workflow will run on. We will use create-react-app to bootstrap this application.

Creating a ReactJS Boilerplate Application

Let's see what commands we will have to use when writing our workflow.

Building & Testing the Application Locally

Let's see how can we use surge to deploy our application locally. Later we will automate this process in our workflow.

Deploying the Application using Surge

Let's install a tool that will help us enforce some code formatting rules in our workflow. And this tool is called prettier.

Using Prettier to Check for Code Formatting Rules

Before getting into the code, let's first discuss the flow of our workflow!

Let's Discuss Our Workflow Plan

Let's create a new repository and setup our protected branches and our codeowners file.

Setting Up Our Repository

Let's create a workflow that will run when someone opens a pull request to merge into the develop branch.

Creating the Develop Pull Requests Workflow

Let's now create the workflow that will run whenever a pull request is merged into develop.

Creating the Develop Merge Pull Request Workflow

Every-time we run our workflow, we install out npm dependencies. These dependencies might be very large and it would be ideal to cache them in order to reuse our cache every-time we run the workflow.

Caching NPM Dependencies

Let's see how can we upload folders that our workflow generates as artifacts

Uploading Artifacts in Our Workflows

Now we need to create a release whenever we push to master. And this release will need to have a version number that we need to automatically generate. Let's discuss how can we achieve this using semantic versioning and conventional commits.

Preview 07:37

Let's use the semantic-release library in order to implement our semantic versioning releases.

Installing semantic-release in Our Project

Now that we have semantic-release configured, let's try and run it in our workflow.

Running semantic-release in Our Workflow

Now that we are generating automatic releases, let's also see how can we upload assets to our releases.

Uploading Release Assets

In our current workflow; when we push to master, the code will be deployed to our assumed staging URL. However, as we planned we need master to be deployed to production.

Deploying to Production when Pushing to Master

Let's use a service called codecov to upload our test coverage reports online.

Uploading Code Coverage Reports to Codecov

In this lecture we will do an extra step that is not necessary for our workflow; however it can be very helpful. We will install some packages that can help us create and validate conventional commits commit message.

Validating Our Commit Messages with Commitlint & Commitizen

Let's as planned create the part in our workflow where we send a slack message when a release is published.

Sending a Slack Message When a New Release is Published

Let's see how can we run a step that opens an automated issue when the workflow fails.

Opening an Automated Issue when the Workflow Fails

Let's finally finalize this section by adding a workflow status badge in our readme file.

Preview 02:25
+ Creating Our Own GitHub Actions
11 lectures 01:46:31

Let's have a quick overview on github actions, what they can do, their types and discuss the actions that we are going to create next.

Preview 05:47

Let's start by creating a simple JavaScript action that will just log a simple string.

Creating a Simple JavaScript Action

In order for our JavaScript code to run without problems, we will have to bundle it into 1 file. Let's use a package called ncc to do this.

Bundling our JavaScript Code into 1 File

Using the core package we can do more than just setting outputs and getting inputs. We can also log debug messages, set environment variables, set secrets and more.

Let's Discover More About the @github/core Package

Let's now create a more useful action. For this one we will call the GitHub Api to open a new issue.

Creating a JavaScript Action for Opening Github Issues

Now that we know all about JavaScript Actions, let's now create a docker action.

Creating a Simple Docker Action

Before creating our slack action using PHP. Let's first create a PHP script that sends a post request to send a slack message.

Preview 10:16

Let's now move our PHP script that we've written into a docker action.

Running our PHP Script using a Docker Action

We have a couple of ways in order to get inputs and github context in docker actions. Let's discover these ways in this lecture.

Populating our Inputs and Context Information Using Environment Variables

Let's finally publish our action into the marketplace.

Publishing Github Actions into the Marketplace
Bonus Lecture
  • You should have basic GitHub knowledge
  • Some lectures will require some basic docker knowledge (it's not necessary if you want to skip it)
  • Creating custom actions requires JavaScript and/or docker knowledge
  • for some sections some stuff must be installed on your machine including: nodejs, npm, docker, composer, php.

GitHub recently released "GitHub Actions" , a CI service competitor to services like TravisCI and CircleCI. GitHub Actions however has the edge of being natively integrated with your GitHub repository. In addition to that, thanks to GitHub's popularity; GitHub Actions has the advantage of having large ecosystem and community. Using GitHub Actions you will find a lot of official and community pre-made workflows and also the actions marketplace. In the actions marketplace you can find tons of actions which are reusable pieces of code that you can use in your workflows to perform certain tasks like deploying code, interacting with API's, sending SMS's, etc...

Learn everything you need to know in order to create GitHub workflows & Actions.

In this course we will comprehensively explore GitHub's CI service. We will learn what GitHub workflows & actions are. And we will discover everything we can do in a GitHub workflow including how to run commands, use actions, trigger workflows, build matrices, filter by branch and more. Then we will use what we learned to create a real-world example of a CI/CD workflow where we will test, build, deploy our code and more. And finally we will learn how to write custom actions and publish them on the marketplace so that other people can use it.

Let's take a look at what will be discussed in each section in more detail:

Section 1

In section 1 we will have a quick conceptual introduction to what workflows, actions, jobs, steps and other terms that we will see are. We will also learn about YAML which is the format used to write workflows in GitHub. Then we will start writing our workflow and take a look at basic things like writing commands, using different shells and using actions including the most common action which is the checkout action.

Section 2

In section 2 we will get a bit deeper and learn different ways that we can use in order to trigger a workflow to run. This includes GitHub events like push and pull_request, cron schedules and also external events. We will also see how to make a workflow only run for certain branches, tags and directory paths.

Section 3

In this section we will see how can we use default environment variables and also how to add custom environment variables. We will also see how to encrypt environment variables that are sensitive and also how to encrypt and decrypt sensitive files that we don't won't to push to our repository. Moreover, we will see the GITHUB_TOKEN environment variable and how to use it for authentication. Also we will take a look at the context information that we can access in our workflows which contains a lot of information about our current workflow and virtual machine and more. Finally we will take a look at different functions that are available to use in our workflows.

Section 4

In section 4 we will see how can we setup matrices, a matrix is a way to run a job multiple times but using different environments. We will also learn how to use docker in our jobs and steps and how to run multiple docker services in our job.

Section 5

In section 5 we will finally use our knowledge to create a more real-world CI/CD example. We will set-up a repository where we have a web app and we need to have a flow for production and development deployment. So we will have 2 branches, 1 for production and another for development and we will write a workflow for each one of these branches to do certain things. These things will differ depending whether we are pushing on production or development branch. We will also have a workflow that will run if someone opened a pull request. The tasks we will perform includes: installing dependencies, caching, testing, checking code format, uploading artifacts, automatically generating a semantic version, deploying to production/staging, creating releases, opening issues, sending slack notifications and more.

Section 6

During the course we will use some actions that are available in the marketplace. In this section we will learn how to create our own actions. Actions can be created using JavaScript or using Docker. In this section we are going to learn about both ways and then we will create a JavaScript action that opens GitHub issues and a docker action that send a slack message which we will write using PHP.

Who this course is for:
  • Developers/Software engineers who need to learn everything about GitHub Workflows & Actions.
  • Developers/Software engineers who want to create a CI/CD workflow using GitHub
  • Developers/Software engineers who would like to learn how to create and publish GitHub Actions.