Book Image

Mastering GitHub Actions

By : Eric Chapman
Book Image

Mastering GitHub Actions

By: Eric Chapman

Overview of this book

Navigating GitHub Actions often leaves developers grappling with inefficiencies and collaboration bottlenecks. Mastering GitHub Actions offers solutions to these challenges, ensuring smoother software development. With 16 extensive chapters, this book simplifies GitHub Actions, walking you through its vast capabilities, from team and enterprise features to organization defaults, self-hosted runners, and monitoring tools. You’ll learn how to craft reusable workflows, design bespoke templates, publish actions, incorporate external services, and introduce enhanced security measures. Through hands-on examples, you’ll gain best-practice insights for team-based GitHub Actions workflows and discover strategies for maximizing organization accounts. Whether you’re a software engineer or a DevOps guru, by the end of this book, you'll be adept at amplifying productivity and leveraging automation's might to refine your development process.
Table of Contents (22 chapters)
Free Chapter
1
Part 1:Centralized Workflows to Assist with Governance
7
Part 2: Implementing Advanced Patterns within Actions
14
Part 3: Best Practices, Patterns, Tricks, and Tips Toolkit

Creating a reusable build pipeline

In Chapter 2, we created a build pipeline for our web app named build-withcache.yml. We’re going to leverage that workflow, make some small adjustments to it, and hopefully be able to implement a reusable caching pipeline into the environment.

Marking a workflow as a reusable workflow

The syntax difference between a normal and reusable workflow is minor. Instead of being called through an event that would have occurred in the repository, it will be triggered exclusively by the workflow_call event from the perspective of reusable workflows.

You may have a workflow that looks similar to this:

name: Pull request linting workflow
on:
  pull_request:

It would look like the following when converted to a reusable workflow:

name: Pull request linting workflow
on:
  workflow_call:

The only change required was to change the event type from pull_request to workflow_call to prepare for it to be called a reusable workflow...