【问题标题】:how create a comment on commit with github actions?如何使用 github 操作创建对提交的评论?
【发布时间】:2020-02-16 11:48:52
【问题描述】:

我在这个配置中使用 github 操作

name: Node CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: install node
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: npm install
        run: npm install
      - name: npm build
        run: npm run build --if-present
      - name: npm test
        run: npm test
      - name: make storybook
        run: npm run build-storybook
      - uses: dswistowski/surge-sh-action@v1
        with:
          domain: 'https://react-strix-$(git rev-parse --short HEAD).surge.sh'
          project: '.out'
          login: straxico@gmail.com
          token: ${{ secrets.SURGE_PASSWORD }}
      - name: deploy image
        run: |
          docker login docker.pkg.github.com --username straxico --password ${{ secrets.DOCKER_PASSWORD }}
          docker build . --file Dockerfile --tag docker.pkg.github.com/straxico/react-strix/master:$(git describe --tags)
          docker push docker.pkg.github.com/straxico/react-strix/master:$(git describe --tags)

我想在最新推送的提交上自动创建评论,包括我的故事书和 docker URL。像“现在”机器人

如何使用 github 操作对提交进行评论?

【问题讨论】:

    标签: github github-api github-actions


    【解决方案1】:

    更新:我写了一个动作来简化创建提交 cmets。我将在下面留下原始解决方案以供参考。

    请参阅commit-comment 了解完整的使用详情。

          - name: Create commit comment
            uses: peter-evans/commit-comment@v1
            with:
              body: |
                This is a multi-line test comment
                - With GitHub **Markdown**
                - Created by [commit-comment][1]
    
                [1]: https://github.com/peter-evans/commit-comment
    

    原始解决方案:以下工作流程应该是一个很好的起点。您可以在此处找到 API 的完整文档: https://developer.github.com/v3/repos/comments/#create-a-commit-comment

    name: commit comment
    on: push
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v1
          - name: Add commit comment
            run: |
              jq -nc '{"body": "test comment"}' | \
              curl -sL  -X POST -d @- \
                -H "Content-Type: application/json" \
                -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
                "https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments"
    

    它将像这样对提交创建评论。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-13
      • 2021-06-07
      • 2019-08-01
      • 2018-02-13
      • 2022-10-14
      • 2021-12-10
      • 2020-05-23
      相关资源
      最近更新 更多