GitHub Actions for EngineersReusable Workflows and Actions

Reusable Workflows and Actions

Build your own Actions and share workflows across repos.

~20 min read

Reusable Workflows and Custom Actions

Calling a reusable workflow

jobs:
  deploy:
    uses: my-org/.github/.github/workflows/deploy.yml@main
    with:
      environment: production
    secrets: inherit

Creating a reusable workflow

In .github/workflows/deploy.yml:

on:
  workflow_call:
    inputs:
      environment:
        required: true
        type: string
    secrets:
      DEPLOY_TOKEN:
        required: true

Creating a custom Action

In action.yml:

name: 'My Custom Action'
description: 'Does something useful'
inputs:
  api-key:
    description: 'API key'
    required: true
runs:
  using: 'node20'
  main: 'dist/index.js'

Build with @actions/core and @actions/github packages.