Skip to main content

Cette version de GitHub Enterprise Server ne sera plus disponible le 2026-03-17. Aucune publication de correctifs n’est effectuée, même pour les problèmes de sécurité critiques. Pour de meilleures performances, une sécurité améliorée et de nouvelles fonctionnalités, effectuez une mise à niveau vers la dernière version de GitHub Enterprise. Pour obtenir de l’aide sur la mise à niveau, contactez le support GitHub Enterprise.

Création de modèles de workflow pour votre organisation

Découvrez comment créer des modèles de workflow pour aider les membres de votre équipe à ajouter plus facilement de nouveaux workflows.

Remarque

GitHub Enterprise Server users should use self-hosted runners. GitHub-hosted runners are not supported.

Creating workflow templates

This procedure demonstrates how to create a workflow template and metadata file. The metadata file describes how the workflow templates will be presented to users when they are creating a new workflow.

  1. If it doesn't already exist, create a new repository named .github in your organization.

  2. Create a directory named workflow-templates.

  3. Create your new workflow file inside the workflow-templates directory.

    If you need to refer to a repository's default branch, you can use the $default-branch placeholder. When a workflow is created the placeholder will be automatically replaced with the name of the repository's default branch.

    Remarque

    The following values in the runs-on key are also treated as placeholders:

    • ubuntu-latest is replaced with [ self-hosted ]
    • windows-latest is replaced with [ self-hosted, windows ]
    • macos-latest is replaced with [ self-hosted, macOS ]

    For example, this file named octo-organization-ci.yml demonstrates a basic workflow.

    YAML
    name: Octo Organization CI
    
    on:
      push:
        branches: [ $default-branch ]
      pull_request:
        branches: [ $default-branch ]
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
          - uses: actions/checkout@v5
    
          - name: Run a one-line script
            run: echo Hello from Octo Organization
    
  4. Create a metadata file inside the workflow-templates directory. The metadata file must have the same name as the workflow file, but instead of the .yml extension, it must be appended with .properties.json. For example, this file named octo-organization-ci.properties.json contains the metadata for a workflow file named octo-organization-ci.yml:

    JSON
    {
        "name": "Octo Organization Workflow",
        "description": "Octo Organization CI workflow template.",
        "iconName": "example-icon",
        "categories": [
            "Go"
        ],
        "filePatterns": [
            "package.json$",
            "^Dockerfile",
            ".*\\.md$"
        ]
    }
    
    • name - Required. The name of the workflow. This is displayed in the list of available workflows.
    • description - Required. The description of the workflow. This is displayed in the list of available workflows.
    • iconName - Optional. Specifies an icon for the workflow that is displayed in the list of workflows. iconName can be one of the following types:
      • An SVG file that is stored in the workflow-templates directory. To reference a file, the value must be the file name without the file extension. For example, an SVG file named example-icon.svg is referenced as example-icon.
      • An icon from GitHub's set of Octicons. To reference an octicon, the value must be octicon <icon name>. For example, octicon smiley.
    • categories - Optional. Defines the categories that the workflow is shown under. You can use category names from the following lists:
    • filePatterns - Optional. Allows the workflow to be used if the user's repository has a file in its root directory that matches a defined regular expression.
  5. To add another workflow template, add your files to the same workflow-templates directory.

Next steps