GitHub Actions Support YAML Anchors

It’s been a long time coming, but GitHub actions support YAML anchors. This isn’t that big of deal as there are better ways to reuse code, but it’s useful in some cases like reusing paths in different triggers, like I do in deploy workflow for this website:

on:
  workflow_dispatch:
  push:
    paths: &paths
      - "website/**.[tj]sx?"
      - "website/**.css"
      - "website/**.astro"
      - "website/public/**"
      - "website/**.md"
      - "website/package.json"
      - "website/pnpm-lock.yaml"
      - "website/tsconfig.json"
      - ".github/workflows/deploy.yml"
    branches:
      - main
  pull_request:
    paths: *paths
    branches:
      - main

Merge keys (represented using <<:) are not supported though, so it’s not possible to use this to “extend” objects.

Share:

If you've come this far with the article you may want to know a thing or two about me if you don't already. You can also read other blog posts or about stuff I've learned recently.

This website is open source. If you've come across a mistake please let me know there. For other types of feedback you can reach out to me through email or social media.