DEV Community

Jacob Hummer
Jacob Hummer

Posted on • Edited on • Originally published at jcbhmr.me

1

TIL you can create your own GitHub Actions workflow templates

So you know how there's this wizard that you can use to create new GitHub Actions right? It turns out that there's a way to add your own GitHub Actions templates there!

All you need to do is add a workflow-templates/*.yml and workflow-templates/*.properties.json pair in your user/.github repository. This works for both organizations (like the official GitHub docs say) and regular users.

workflow-templates/say-hi.yml

name: Say hi!
on:
  push:
    branches: [$default-branch]
jobs:
  say-hi:
    runs-on: ubuntu-latest
    steps:
      - name: Echo "Hi!" to the user
        run: echo "Hi!"
Enter fullscreen mode Exit fullscreen mode

workflow-templates/say-hi.properties.json

{
    "name": "Say hi!",
    "description": "Says hi to the user",
    "iconName": "emoji-wave",
    "categories": ["Automation"],
    "filePatterns": ["README.md"]
}
Enter fullscreen mode Exit fullscreen mode

workflow-templates/emoji-wave.svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <text y="75px" font-size="75px">👋</text>
</svg>
Enter fullscreen mode Exit fullscreen mode

📚 Further reading: Creating starter workflows for your organization (also works for users too)

How you might want to use this

A great way to take advantage of this template feature is to make workflow templates for things you do often or in every repository. Think like...

  1. Repetitive Node.js test.yml workflow
  2. Workflow to deploy to GitHub Pages from npm run build
  3. Mirroring wiki/ in your Git reposutory to a GitHub wiki page
  4. Enabling /help in any issue

Anytime you think "I wish I could just copy-paste this workflow from my previous project" then it might be time to make that a template.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay