首页 > 解决方案 > Github Actions 有模板吗

问题描述

由于我的 Github Actions 中有重复的步骤,我想创建一个模板。让我们举个例子

name: ci
on: ["push"]

jobs:
  build-and-test:
    strategy:
      matrix:
        os: [ubuntu-latest]

    runs-on: ${{ matrix.os }}
    steps:
      - name: checkout
        uses: actions/checkout@v1

      - name: do stuff
        run: |
          bash stuff

是否可以仅将步骤保存在单独的文件中?然后导入?

标签: github-actions

解决方案


Unfortunately it does not look like github-actions supports reusing workflows. Not even YAML anchors are supported.

It looks like the only way to share steps (not setup) is to create actions.

Update: A storm brewing

I have also caught wind of the possibility of reusing actions. Follow the issue to stay up-to-date.


推荐阅读