GithubHelp home page GithubHelp logo

Consume list-files about paths-filter HOT 3 CLOSED

dorny avatar dorny commented on May 22, 2024
Consume list-files

from paths-filter.

Comments (3)

dorny avatar dorny commented on May 22, 2024

Hello,

GitHub context variables are not mapped to shell variables (unless you set them as env variables).
GitHub workflow engine will instead do substitution before your shell command is executed.
You have to use ${{ <expression> }} syntax instead of ${<expression>}.

Next things is what is actually output of this actions. For your example it would be:

{
  "server": "true",
  "server_files": "\"server/pricinf/main.go\" \"server/sendmain/packGreet/logic.go\"",
  "changes": ["server"]
}

You wrote you are trying to get list of services which changed, but you can't get that directly out of this.
list-files option is useful mostly when you want to pass list of changed files directly as argument to linter.
If your linter operates on a whole folder I would chose different approach.

You could have for example this filter:

 with:
   filters: |
     pricing: 'server/pricing/**'
     sendmail: 'server/sendmail/**'

Afterwards you have several options:

  • use if conditions to selectively execute steps in service folders
  • use ${{ fromJson(needs.some-job.outputs.changes) }} as parameter for matrix job
  • use join(fromJson(steps.changes.outputs.changes), ' ') to transform changes output in JSON format to be usable in shell for loop. This requires your service names to not contain any special character or whitespace.

For example the last options would look like this:

 - name: Printing changed services
      run: |
        for val in ${{ join(fromJson(steps.changes.outputs.changes), ' ') }}; do echo $val; done

from paths-filter.

dorny avatar dorny commented on May 22, 2024

Hey @Kmelow, is your issue solved? Unless you have more issues/questions I will close this.

from paths-filter.

ace-astro avatar ace-astro commented on May 22, 2024

Hello @dorny,

Thanks for the suggestion on filters above. The configuration is cleaner.

And I implemented a script using your suggested example and it is all good 👍

- name: Printing changed services
      run: |
        for val in ${{ join(fromJson(steps.changes.outputs.changes), ' ') }}; do echo $val; done

🙇 Thank you

from paths-filter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.