Micro Focus is now part of OpenText. Learn more >

You are here

You are here

GitHub Actions goes full stack: How to put it to work for your software team

public://pictures/billd.jpg
Bill Doerrfeld Consultant, Doerrfeld.io
 

GitHub has, for some time, been an innovator in software collaboration and communication styles. That's especially true with new event-driven scenarios. 

You recently learned about the pre-release version of GitHub Actions. Now, with the new beta rollout, here's a deeper dive to explore how to truly put GitHub Actions to work for your software team. 

What follows is a review of GitHub Actions, a discussion of new features in this release, and a demonstration of some pre-built Actions and Workflows. There's also a sample CI/CD workflow using Actions, so you can discover its automation power.

GitHub Actions: An overview

For a quick refresher, GitHub Actions is a new offering that allows developers to program reactions throughout the GitHub platform. Written in YAML, these reusable pieces of code can trigger new actions based on events, such as creating a new repository, merging a pull request, or testing a build.

GitHub Actions is a community-powered platform. Many of the Actions and Workflows are built by community developers. Using Actions, GitHub posits that developers can "automate [their] workflow from idea to production."

New CI/CD features

In response to developer demand, the latest GitHub Actions beta addresses continuous integration (CI) and continuous development (CD) requirements more head-on. As GitHub describes, "Actions is the democratization of CI/CD and software automation."

New features in the beta Actions update include: 

  • Matrix builds: Developers can test multiple versions in parallel.
  • Platform support: Developers can test on any platform: Linux, macOS, Windows, and containers.
  • Live logging: Real-time logs are streamed to the Actions console. Logs provide deep link capabilities, with permalinks to aid in collaborative testing procedures. 
  • Enhanced language support: Node.js, Python, Java, PHP, Ruby, C/C++, .NET, Android, and iOS.
  • Suggested workflows: Relevant workflows are automatically suggested to users based on their project details. 

All these features are free for public repositories and serve a key purpose for GitHub Actions: Reusability. Developers can treat Actions like code to reuse in their workflows, now regardless of platform or language choice.

Automating a sample CI/CD pipeline using Actions

From code push and testing to deployment, GitHub Actions could essentially automate each component of a DevOps pipeline in an event-driven fashion.

To create a workflow, you begin with a .github/main.workflow file. GitHub puts no limit on the number of Workflows or Actions blocks that can be threaded together.

A simple workflow structure may look like this YAML text:

workflow "IDENTIFIER" {
  on = "EVENT"
  resolves = "ACTION2"
}
action "ACTION1" {
  uses = "docker://image1"
}
action "ACTION2" {
  needs = "ACTION1"
  uses = "docker://image2"
}

You can also schedule a Workflow to recur. Developers could use repeating Workflows as a solution for continuous scanning, vulnerability checking, automated deployment, or other routine tasks.

Scheduling a Workflow to recur is simple. Here are example parameters:

workflow "IDENTIFIER" {
on = "schedule(*/15 * * * *)"
  resolves = ["ACTION1", "ACTION2"]
}

Developers can browse the Starter Workflows to see some ready-made workflows. For example, here is a continuous integration workflow solution designed for Android:

name: Android CI
on: [push]
jobs:
  build:
  runs-on: ubuntu-latest
  steps:
 - uses: actions/checkout@v1
 - name: set up JDK 1.8
  uses: actions/setup-java@v1
 with:
  java-version: 1.8
 - name: Build with Gradle
 run: ./gradlew build

The above Workflow initiates a build running on Ubuntu, and incorporates additional actions to configure the process. Similar starter CI Workflows also are ready for Ruby gems, Docker images, Python packages, and other environments.

As developers will surely find, Actions and Workflows can help automate building, testing, and deploying applications—great for DevOps fluidity. You can also use Actions to automate other DevOps tasks, such as managing issues, automating releases, collaborating with your user base, and more.

Workflows can have up to 100 actions and run for up to 58 minutes, granting a near-endless number of possible combination chains.

Github Actions limitations

When we last covered Actions, the alpha release didn't specify exact calling rates and other usage limitations. Now, the Actions beta update offers clarity on usage scope.

  • Actions is free only for public repositories
  • Developers can utilize only 2,000 minutes per month.

  • Each workflow can run for up to 58 minutes (including queuing and execution time).

  • Each workflow can run up to 100 actions (including build and other meta steps).

  • Only two workflows can be running concurrently per repository.

  • Actions are not allowed to trigger other Workflows. As the docs explain: "A push, deployment, or any task performed within an action with the provided GITHUB_TOKEN will not trigger a workflow listening on push, deploy, or any other supported action triggers."

  • GitHub limits Docker container logs to a maximum size of 64KB.

  • Docker container logs are limited to a maximum size of 64KB.

  • Developers can issue 1,000 API requests in an hour across all actions within a repository.

 Who is GitHub Actions for?

Operational leads or DevOps heads may leverage Actions to develop unique pathways customized to their specific policies and development culture. With the recent focus on CI/CD, GitHub Actions is becoming an even stronger force for software release automation.

Since Actions' unveiling, developer community response has been overwhelmingly positive. There have been hundreds of community-generated Actions and Workflows. With such a positive response from the developer community, Actions appear to be solidified as a staple feature.

Development automation made easier

New features within the GitHub Actions beta update zero in on core needs for development automation needs. For example, Matrix Builds is a helpful feature for testing in parallel, and added support for additional platforms and languages open the door to more developers.

With over 40 million developers, GitHub has become a very popular choice for Git-style application development. Now with Actions, GitHub may continue to displace startups in the CI/CD realm of DevOps. Others view it as friendly competition.

A full release is expected on November 13. GitHub mentions upcoming features such as self-hosting and Actions for GitHub Enterprise Server. Keep in mind that, although Actions is in a public beta period, GitHub doesn't recommend its use for "high-value workflows."

Keep learning

Read more articles about: App Dev & TestingApp Dev