# How to port "on paths" from github actions to Circle?

**URL:** <https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016>\
**Category:** Build Environment\
**Created:** [May 11, 2022, 2:51pm UTC](https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016 "2022-05-11T14:51:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RealNC](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/realnc/32/30137_2.png) [@RealNC](https://discuss.circleci.com/u/RealNC)\
**Post date:** [May 11, 2022, 2:51pm UTC](https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016/1 "2022-05-11T14:51:44Z")

</div>

Hello!

I want to build some docker images on Circle. I don’t want to build every single dockerfile in the git repository, but only those that actually changed. Also, only pushing to the master branch should build anything. All other branches are ignored.

On Github Actions, I do the following in each yml file. There’s one yml file per docker image. `build-docker-foo-linux.yml` for example has this at the top:

```yaml
name: Build Linux docker image foo
on:
  workflow_dispatch:
  push:
    branches:
      - master
    paths:
      - 'foo/linux/Dockerfile'

jobs:
  # ...

```

If the push is not on master, and the file `foo/linux/Dockerfile` didn’t change, nothing is executed. The workflow is just skipped altogether.

I’m trying to move this to CircleCI, and I can’t find anything on how to make this work. I’ve been searching since yesterday, and all solutions I could find don’t work. They all resolve around parsing the output of `git show --name-only ${CIRCLE_SHA1}`, which just doesn’t work, since it can’t detect anything other than what’s in the diff of the current commit. Other commits are ignored.

How on earth do I move this to CircleCI?

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [May 11, 2022, 4:31pm UTC](https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016/2 "2022-05-11T16:31:57Z")

</div>

The first part where you only want to do any action if the master branch is touched can be handled with branch filters

```
https://support.circleci.com/hc/en-us/articles/115015953868-Filter-workflows-by-branch-

```

2 things to remember - spaces matter and there is a lot of indenting when using this structure and to get this to work the config.yml has to be updated across all the defined branches in the repo.

The second part is more complicated as CircleCI does not have access to the same detailed ‘state’ information that github has when it is also hosting the repo. CircleCI has a more complicated solution detailed here, but I’ve never tried to use it

```
 https://circleci.com/docs/2.0/configuration-cookbook/#branch-filtering-for-job-steps

```

Another solution may be to look at the artefact storing feature - so you could use a script to store the checksum of the file(s) you want to track between sessions.

My personal solution has so far been to use a self-hosted runner that can hold state between jobs. So my script can just compare a file between the current git pull and the last pull. If it sees a difference it runs the job and if it completes just copies the current git pull over the stored last pull, ready for the next time.

---

<div class="post-metadata">

**Author:** ![RealNC](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/realnc/32/30137_2.png) [@RealNC](https://discuss.circleci.com/u/RealNC)\
**Post date:** [May 12, 2022, 1:07pm UTC](https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016/3 "2022-05-12T13:07:07Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [May 22, 2022, 1:07pm UTC](https://discuss.circleci.com/t/how-to-port-on-paths-from-github-actions-to-circle/44016/4 "2022-05-22T13:07:09Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
