Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing changed file list to a python script #102

Closed
arielelkin opened this issue Aug 23, 2021 · 1 comment
Closed

Passing changed file list to a python script #102

arielelkin opened this issue Aug 23, 2021 · 1 comment

Comments

@arielelkin
Copy link

I have a Python script which should process each file that has been changed in a PR. Here's my yml file:

jobs: 
  process-files:
    name: Process files
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2
    - uses: dorny/paths-filter@v2
      id: filter
      with:
        list-files: json
        filters: |
          changed:
            - '**'
    - name: Process changed files
      run: |
        echo "${{ steps.filter.outputs.changed_files }}"
        python process.py

In the run step, the first echo correctly prints all the changed files. However, when I try to print them from within process.py:

import os
os.system("echo \" ${{ steps.filter.outputs.changed_files }} \" ")

I get a sh: 1: Bad substitution error

Any ideas?

@arielelkin
Copy link
Author

jobs: 
  process-files:
    name: Process files
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v2
    - uses: dorny/paths-filter@v2
      id: filter
      with:
        list-files: json
        filters: |
          changed:
            - '**'
    - name: Process changed files
      run: |
        python process.py '${{ steps.filter.outputs.changed_files }}'

And then in process.py:

new_files = list(json.loads(sys.argv[1]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant