GitHub Actions — How to Add Comments in YAML Files

GitHub Actions are a seamless way to integrate automated tasks into your repository. Sometimes it’s helpful to leave a comment in the action’s YAML file. Yes! Workflow files in GitHub Actions support comments!

This tutorial shows you how to add comments to GitHub Actions workflow files.

GitHub Actions Series Overview

Add Comments in GitHub Actions YAML Files

A previous tutorial walked you through the process of running GitHub Actions on a schedule. You’re using a cron notation to define the schedule.

I can’t remember how to translate a given cron definition. The quickest way to know when the cron runs is by adding a comment.

Luckily comments are supported in the YAML configuration files of GitHub Action workflows. Comments start with a # symbol. Everything in the same line coming after the # symbol will be interpreted as a comment:

name: Run tests

on:  
  push:
  pull_request:
  schedule:
    - cron: '0 0 * * *'    # every day at midnight

jobs:  
  test:
    runs-on: ubuntu-latest

    # Comments in YAML start with a # (hashtag symbol)
    # Comment your thoughts for yourself or coworkers :)
    steps:
    - name: …

That’s it!


Mentioned Resources

Explore the Library

Find interesting tutorials and solutions for your problems.