GitHub Actions Cookbook

Book description

Authored by a Microsoft Regional Director, this book shows you how to leverage the power of the community-driven GitHub Actions workflow platform to automate repetitive engineering tasks

Key Features

  • Automate CI/CD workflows and deploy securely to cloud providers like Azure, AWS, or GCP using OpenID
  • Create your own custom actions with Docker, JavaScript programming, or shell scripts and share them with others
  • Discover ways to automate complex scenarios beyond the basic ones documented in GitHub

Book Description

Say goodbye to tedious tasks! GitHub Actions is a powerful workflow engine that automates everything in the GitHub ecosystem, letting you focus on what matters most.

This book explains the GitHub Actions workflow syntax, the different kinds of actions, and how GitHub-hosted and self-hosted workflow runners work. You’ll get tips on how to author and debug GitHub Actions and workflows with Visual Studio Code (VS Code), run them locally, and leverage the power of GitHub Copilot. The book uses hands-on examples to walk you through real-world use cases that will help you automate the entire release process. You’ll cover everything, from automating the generation of release notes to building and testing your software and deploying securely to Azure, Amazon Web Services (AWS), or Google Cloud using OpenID Connect (OIDC), secrets, variables, environments, and approval checks.

The book goes beyond CI/CD by demonstrating recipes to execute IssueOps and automate other repetitive tasks using the GitHub CLI, GitHub APIs and SDKs, and GitHub Token. You’ll learn how to build your own actions and reusable workflows to share building blocks with the community or within your organization.

By the end of this GitHub book, you'll have gained the skills you need to automate tasks and work with remarkable efficiency and agility.

What you will learn

  • Author and debug GitHub Actions workflows with VS Code and Copilot
  • Run your workflows on GitHub-provided VMs (Linux, Windows, and macOS) or host your own runners in your infrastructure
  • Understand how to secure your workflows with GitHub Actions
  • Boost your productivity by automating workflows using GitHub's powerful tools, such as the CLI, APIs, SDKs, and access tokens
  • Deploy to any cloud and platform in a secure and reliable way with staged or ring-based deployments

Who this book is for

This book is for anyone looking for a practical approach to learning GitHub Actions, regardless of their experience level. Whether you're a software developer, a DevOps engineer, anyone who has already experimented with Actions, or someone completely new to CI/CD tools like Jenkins or Azure Pipelines, you’ll find expert insights in this book. Basic knowledge of using Git and command lines is a must.

Table of contents

  1. GitHub Actions 
Cookbook
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
    4. Conventions used
    5. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Get in touch
    7. Share your thoughts
    8. Download a free PDF copy of this book
  6. Chapter 1: GitHub Actions Workflows
    1. Technical requirements
    2. The GitHub ecosystem
    3. Hosting and pricing for GitHub
    4. Pricing for GitHub Actions
    5. GitHub Marketplace
    6. Using the workflow editor for writing workflows
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Using secrets and variables
      1. Getting ready
      2. How to do it…
      3. There’s more…
    8. Creating and using environments
      1. Getting ready
      2. How to do it…
      3. There’s more…
  7. Chapter 2: Authoring and Debugging Workflows
    1. Using Visual Studio Code for authoring workflows
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    2. Developing workflows in branches
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Linting workflows
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Writing messages to the log
      1. Getting ready…
      2. How to do it…
      3. How it works…
    5. Enabling debug logging
      1. How to do it…
      2. There’s more…
    6. Running your workflows locally
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
  8. Chapter 3: Building GitHub Actions
    1. Technical requirements
    2. Creating a Docker container action
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Adding output parameters and using job summaries
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Creating a TypeScript action
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Creating a composite action
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Using github-script in a composite action to add a comment to an issue
      1. How to do it…
      2. How it works…
      3. There’s more…
    7. Sharing actions to the marketplace
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
  9. Chapter 4: The Workflow Runtime
    1. Technical requirements
    2. Setting up a self-hosted runner
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Auto-scaling self-hosted runners
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Scaling self-hosted runners with Kubernetes using ARC
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Runners and runner groups
      1. Getting ready…
      2. How to do it…
    6. GitHub-hosted runners
      1. Getting ready…
      2. How to do it…
      3. How it works…
  10. Chapter 5: Automate Tasks in GitHub with GitHub Actions
    1. Technical requirements
    2. Creating an issue template
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There is more…
    3. Using the GitHub CLI and GITHUB_TOKEN to access resources
      1. Getting ready…
      2. How to do it…
      3. How it works…
    4. Using environments for approvals and checks
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There is more…
    5. Reusable workflows and composite actions
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There is more…
  11. Chapter 6: Build and Validate Your Code
    1. Technical requirements
    2. Building and testing your code
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Building different versions using a matrix
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Informing the user on details of your build and test results
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Finding security vulnerabilities with CodeQL
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Creating a release and publishing the package
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Versioning your packages
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Generating and using SBOMs
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    9. Using caching in workflows
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  12. Chapter 7: Release Your Software with GitHub Actions
    1. Technical requirements
    2. Building and publishing a container
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Using OIDC to securely deploy to any cloud
      1. Getting ready…
      2. How to do it…
      3. How it works…
    4. Environment approval checks
      1. Getting ready…
      2. How to do it…
      3. How it works…
    5. Releasing the container application to AKS
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Automating the update of your dependencies
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Clean up
    8. Summary
  13. Index
    1. Why subscribe?
  14. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share your thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: GitHub Actions Cookbook
  • Author(s): Michael Kaufmann
  • Release date: April 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781835468944