首页 > 解决方案 > 如何在 GitHub 操作 YML 文件中添加评论?

问题描述

在以下语法中:

jobs:
  testing:
    name: some test
    runs-on: [ self-hosted, linux, xyz ]
    steps:
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.15.0
        id: go

      - name: Configure git client
        run: git config --global url."ssh://git@github.com:".insteadOf "https://github.com/"

如何添加run git client to fix some issue作为运行命令的注释?

标签: githubgithub-actions

解决方案


tl; 博士

  • 利用: #
- run: git config --global url."ssh://git@github.com:".insteadOf "https://github.com/" # run git client to fix some issue
+ run: |
+   : # run git client to fix some issue
+   git config --global url."ssh://git@github.com:".insteadOf "https://github.com/"

ts; 博士

我一直在搜索官方 GitHub 文档并四处搜索,但找不到任何工作示例。

我通过使用:刚刚返回的操作数true后跟#这样的评论得出了答案:

jobs:
  testing:
    name: some test
    runs-on: [ self-hosted, linux, xyz ]
    steps:
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.15.0
        id: go

      - name: Configure git client
        run: |
          : # run git client to fix some issue
          git config --global url."ssh://git@github.com:".insteadOf "https://github.com/"

推荐阅读