45

I have the following action on Github actions that automatically packs and deploy a package to nuget.org every time a PR gets merged into master.

name: Nuget Deploy

on:
  push:
    branches: [ master ]

jobs:
  build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.101
    - name: Generate Nuget package
      run: dotnet pack
      working-directory: DateOverride
    - name: Deploy to nuget.org
      run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_DEPLOY_KEY }} -s https://api.nuget.org/v3/index.json
      working-directory: DateOverride/DateOverride/bin/Debug

But I would like that it was not run if my update is only a README.md update, is it possible to do so?

2

2 Answers 2

90

I'd think the paths-ignore setting should help:

on:
  push:
    branches:
      - master
    paths-ignore:
      - '**/README.md'
3
  • 14
    For those who wants to ignore all markdown files, you can use : **.md
    – Bertrand P
    Commented Oct 7, 2021 at 16:07
  • 2
    If you want to test your paths-ignore in a pull request, be sure to temporarily add the yml file to ignore list too.
    – Tim Graham
    Commented Dec 2, 2021 at 1:35
  • 1
    [skip ci] in your commit: docs.github.com/en/actions/managing-workflow-runs/…
    – mas
    Commented Aug 24, 2023 at 22:54
3

You might want to combine your current GitHiub Action with another like MarceloPrado/has-changed-path

This action outputs whether a path or combination of paths has changed in the previous commit.
[This] action is meant to be used inside your job steps, not at the root of your workflow file

Or (opposite filter): dorny/paths-filter

With this Github Action you can execute your workflow steps only if relevant files are modified.

Not the answer you're looking for? Browse other questions tagged or ask your own question.