I have a repo, in which there is one folder at the root with a Makefile to build a C library. In the same repo, there is another folder at the root with a folder with another Makefile for building a node C addon via Node-API, and a small JS/TS API using said addon. The NAPI addon is dependent on the C library.

I have a workflow file for the C which runs when there is a commit on the C folder, and runs with any push or PR. I have another workflow file that runs when there is a commit+push/PR to the JS/TS folder, OR when the C workflow has completed successfully.

My goal is (of course) to only have the minimal amount of workflows run, depending on "how high in the stack the commits were". If commits touch only the C, I want both the C and NAPI addon to be checked. If commits touch only the NAPI addon, I want only the NAPI addon to be checked. If commits touch both the C and NAPI addon, I want both the C and NAPI to be checked; but for NAPI to only be checked once.

For now, when the commits touch both the C and NAPI addon, the CI for the NAPI addon is launched twice: once for the commits affecting the NAPI folder, once for the successful completion of the C workflow.

How do I fix this ?

NB: I've tried using fkirc/skip-duplicate-actions@master, but it didn't do the job.

2 Answers 2


We have similar situations whereby you want the action to do different things based on the files changed within the commit. You could generate a list of files modified within the PR/commit (within your action) using something like (simplified for ease of reading):

# export a list of changed files

export FILESCHANGED=$( curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' --header 'content-type: application/json' --silent https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} | jq '.files[].filename')

# writes changed files into a text file whilst removing quotes and substituting a space for a newline (each file will appear on a separate line).

echo ${FILESCHANGED} | tr -d [\"] | sed 's/ /\n/g' >> files_changed.txt

# display the list of changed files for visibility in the workflow

echo "Files changed in this commit"

cat files_changed.txt

you could then examine the list of files that are part of the commit/PR and run your logic accordingly in steps in a simple script

if C makefile is contained in the list
  run C makefile
  do not run C makefile.

if C makefile is contained and/or if NAPI makefile is contained 
  run NAPI makefile
else if neither exist in list 
  do not run NAPI makefile.

Logic will then dictate what runs based on what is contained in the commit also this would turn this into a single workflow from what I can see.

Hope that helps.


So in the same repo you have separate Makefiles for both components (the core library and the add-on), but one of those components (the library) is also actually a dependency to the other.

I suggest merging these into a single Makefile. In the GitHub workflow, run make all and use GitHub action caching so that make only rebuilds components if their dependencies have been modified.

Then, use the concurrency feature in GitHub workflows, if you don’t want multiple runs to overlap simultaneously.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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