【问题标题】:Github workflow does not trigger on push for path based filteringGithub 工作流不会在推送基于路径的过滤时触发
【发布时间】:2021-08-15 10:24:06
【问题描述】:

我有一个工作流,每当推送到开发分支时,我都需要运行该工作流。我正在使用基于路径的过滤。这是工作流程的sn-p

name: Push to XYZ

on:
  push:
    branches: [ Develop ]
    paths:
    - '!.github/**'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Extract commit
        run: |
          echo "Sending commit $GITHUB_SHA for $GITHUB_REPOSITORY"
          curl -XPOST ......

所以想法是,在推送到 Develop(直接或通过拉取请求)时,如果所做的更改位于 .github 文件夹以外的文件夹或文件中,则工作流应该运行。此工作流程已在 .github/workflows/file.yaml 推送到开发。我从开发中取出一个分支,对不在.github 中的文件进行更改,然后提出 PR 并将其合并。但是工作流没有运行

我错过了什么吗?

没有语法或缩进问题,因为我能够手动触发工作流程并且工作正常

【问题讨论】:

    标签: github github-actions


    【解决方案1】:

    你需要的是首先添加过滤器以允许某些文件夹,这里就是

    name: Push to XYZ
    
    on:
      push:
        branches: [ main ]
        paths:
        - '**'
        - '!.github/**'
    
      # Allows you to run this workflow manually from the Actions tab
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - name: Extract commit
            run: |
              echo "Sending commit $GITHUB_SHA for $GITHUB_REPOSITORY"
    

    【讨论】:

      猜你喜欢
      • 2021-08-05
      • 2022-10-07
      • 2021-10-20
      • 2021-01-12
      • 1970-01-01
      • 2022-10-16
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      相关资源
      最近更新 更多