【问题标题】:Is it possible to rerun github actions (after commit) if it has failed earlier如果之前失败,是否可以重新运行 github 操作(提交后)
【发布时间】:2021-11-01 13:03:55
【问题描述】:

当 PR 打开时,我正在运行 github 操作。这工作正常。我的问题是,如果they failed in their earlier execution due to any errors.

是否可以再次运行 github 操作

简而言之,如果我对上一个错误进行修复,我想再次运行 github 操作。目前,如果我提交修复,则不会触发 github 操作。

name: Node.js CI

on:
  push:
    branches: [main]
  pull_request:
    types: [opened]
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - run: npm ci
      - run: npm run build --if-present
      - run: npm test
      - name: serverless deploy
        if: ${{github.event_name=='push'}}
        uses: serverless/github-action@master
        with:
          args: deploy
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

【问题讨论】:

    标签: github continuous-integration github-actions


    【解决方案1】:

    它不起作用,因为您有 event_type opened,它在以下情况下触发:

    创建拉取请求

    如果您想为下一次提交运行您的工作流程,您需要添加事件synchronize

    所以你将拥有:

    on:
      push:
        branches: [main]
      pull_request:
        types: [opened, synchronize]
        branches: [main]
    

    on:
      push:
        branches: [main]
      pull_request:
        branches: [main]
    

    详情请查看this

    【讨论】:

    • 我试过这个,但它没有触发任何提交操作
    • 我认为应该是 types:[opened,synchronize]branches: [main]
    • 在这种情况下,它将触发 PR 到主分支的任何事件。最好先从这个开始。
    • @JatinMehrotra 如果我的回复对您有帮助,您可以考虑点赞吗?
    • 你标记的是答案 ;) 我很感激! How can I upvote answers and comments?
    猜你喜欢
    • 1970-01-01
    • 2012-06-29
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 2022-08-17
    • 2019-07-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多