如果之前失败了,是否可以重新运行 github 操作(提交后)

Is it possible to rerun github actions (after commit) if it has failed earlier

当 PR open.This 工作正常时,我正在 运行 宁 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 }}

它不起作用,因为你有 event_type opened,它在以下时间触发:

pull request is created

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

所以你要去的是:

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

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

请查看 this 了解更多详情。