GitHub Actions Overview

Premier Developer

Developer

In this post, App Dev Managers Bernard Apolinario, Sujith Nair, and Latha Natarajan give a thorough overview of GitHub Actions.


GitHub Actions enables you to create custom workflows directly in your GitHub repository. You can discover, create, and share actions to perform any job you’d like, including CI/CD, and combine actions in a completely customized workflow. You can create continuous integration (CI) workflows that build, and test projects written in different programming languages.

GitHub Actions for JavaScript and TypeScript

GitHub Actions for Python

GitHub Actions for Java

GitHub Actions for Docker

Workflows run in Linux, macOS, Windows, and containers on GitHub-hosted machines, called ‘runners’. Alternatively, you can also host your own runners to run workflows on machines you own or manage. For more information see, “About self-hosted runners.”

Workflows

A workflow is a configurable automated process made up of one or more jobs. You can setup workflows in your repository to build, test, package, release, or deploy any project on GitHub. Workflows are stored in the .github/workflows directory in the root of your repository. There is a requirement to have at least one job in a workflow. A job contains a set of steps that perform tasks (Commands or Actions)

Workflows can be configured to start when:

  • An event occurs on GitHub
    • a commit is pushed
    • issue or pull is requested
  • A scheduled event begins
  • An external event occurs

More details on workflow triggers can be found here

Workflows in GitHub Actions are created as YAML files and saved in your repository. Once the workflow has been created and triggered, the logs, test results, artifacts, and the status for each step will be available for review. For more information see “Managing a workflow run.”

Matrix builds

GitHub Actions saves you time by allowing you to test on multiple operating systems, platforms, and language versions at the same time using a build matrix.

You can create a matrix to run workflows on more than one operating system. You can also specify more than one matrix configuration. This example creates a matrix of 6 jobs:

  • 2 operating systems specified in the os array
  • 3 Node.js versions specified in the node array

When you define a matrix of operating systems, you must set the value of runs-on to the matrix.os context property you defined.

A screenshot of a cell phone Description automatically generated

Supported configurations options for GitHub hosted runner can be found at “Virtual environments for GitHub-hosted runners.”

Live logs

GitHub Actions allows you to see your workflow run in real-time. If your workflow run fails, you can see the step that caused the failure and review the failed steps build logs. The duration for each step is logged. A link to the specific line in the log file is shareable with your team when troubleshooting. The full build logs and artifacts for a workflow run is available for 90 days. (Read-level access can perform this function)

To review the logs:

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Actions.

Actions tab in the main repository navigation

  1. In the left sidebar, click the workflow you want to see.

Workflow list in left sidebar

  1. Under “Workflow runs”, click the name of the run you want to see.

Name of workflow run

  1. In the left sidebar, click the job you want to see.

List of jobs in left sidebar

  1. To expand the log for a failed step, click the step.

Failed step name

  1. Optionally, to get a link to a specific line in the logs, click on the step’s line number. You can copy the link from the address bar of your web browser.

Button to copy link

Build logs are also searchable. You can search the build logs for a specific step. Only expanded steps are included in the results. (Read-level access can perform this function)

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Actions.

Actions tab in the main repository navigation

  1. In the left sidebar, click the workflow you want to see.

Workflow list in left sidebar

  1. Under “Workflow runs”, click the name of the run you want to see.

Name of workflow run

  1. In the left sidebar, click the job you want to see.

List of jobs in left sidebar

  1. To expand each step, you want to include in your search, click the step.

Step name

  1. In the upper-right corner of the log output, in the Search logs search box, type a search query.

Search box to search logs

As mentioned earlier, the logs are available for review for up to 90 days. If you need to keep the logs as well as the artifacts longer, you can download them from your workflow run. (Read-level access can perform this function)

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Actions.

Actions tab in the main repository navigation

  1. In the left sidebar, click the workflow you want to see.

Workflow list in left sidebar

  1. Under “Workflow runs”, click the name of the run you want to see.

Name of workflow run

  1. To download logs, use the Download logs drop-down menu, and select the logs you want to download.

Download logs drop-down menu

For more information, see “Persisting workflow data using artifacts.”

If the need arises to delete logs, you can delete them from your workflow run by following the steps below: (Write-level access is required to perform this function)

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Actions.

Actions tab in the main repository navigation

  1. In the left sidebar, click the workflow you want to see.

Workflow list in left sidebar

  1. Under “Workflow runs”, click the name of the run you want to see.

Name of workflow run

  1. To delete the log files, click the Delete all logs button and review the confirmation prompt.

Delete all logs  After deleting logs, the Delete all logs button is removed to indicate that no log files remain in the workflow run.

Built-in secret store

Secrets are encrypted variables that you create in a repository or organization. The secrets created are used within the GitHub Action workflows. The secrets could be login credentials, configuration settings, or any sensitive value that would be used by the workflow tasks. You can securely connect to an Azure subscription using a service principal generated via the Azure CLI. The encrypted secret output of the command can be safely stored in the GitHub Actions built-in secret store. The access to secrets can be for all repositories or limited to only private repositories or a list of repositories.

  • To create secrets at the organization level, you must have admin access.
  • To create secrets for a user account repository, you must be the repository owner.
  • To create secrets using the REST API, you must have “write” access to the repository. For more information, see “GitHub Actions secrets API.”

Follow the steps below to add a new secret:

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click  Settings.

Repository settings button

  1. In the left sidebar, click Secrets.
  2. Click Add a new secret.
  3. Type a name for your secret in the Name input box.
  4. Enter the value for your secret.
  5. Click Add secret.

Community-powered workflows

One of the important features of GitHub Actions is the ability to re-use existing workflows or build on thousands of free community created actions. You can extend and improve your GitHub workflows by utilizing free and paid tools. GitHub has partnered with industry leading solution providers to include:

  • Atlassian for automating JIRA
  • Twilio for sending SMS messages in your workflow
  • Cloudflare for deploying a Cloudflare Worker
  • SonarCloud for scanning code quality
  • JFrog for setting up and configuring the JFrog CLI
  • Mabl for automated functional testing

As of April 2020, GitHub Marketplace has over 3200 Actions. Some of the favorites are:

  • Actions Label Commenter – Automatically adds a label based on a templated message.
  • Actions Comment Run – Allows you to run any script in a GitHub issue comment. Program your bot to say “hello, world”, post an image or gif, add links, run a command, and more.
  • Misspell Fixer – Automatically fixes typos and mistakes in your source code and docs
  • TODO to Issue  – Converts your #TODO comments to GitHub issues when a new comment is added

If you’ve created an action that you think would be useful for other users, you can list free and paid tools in the GitHub Marketplace. Anyone can publish an action in GitHub Marketplace as long it meets the GitHub Marketplace Terms of Service.

1 comment

Leave a comment