-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8446626
commit d291020
Showing
3 changed files
with
83 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: 'Changed files in PR' | ||
description: 'Get all changed files in a Pull Request' | ||
author: 'ericLemanissier' | ||
inputs: | ||
filter: | ||
description: "The filter" | ||
required: false | ||
default: "" | ||
|
||
outputs: | ||
all_changed_files: | ||
description: List of all copied, modified, and added files. | ||
value: ${{ steps.changed-files.outputs.all_changed_files }} | ||
any_changed: | ||
description: Return true only when any files provided using the files input have changed. | ||
value: ${{ steps.changed-files.outputs.any_changed }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v4 | ||
- name: Get changed files | ||
id: changed-files | ||
shell: python | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
import json | ||
import subprocess | ||
import fnmatch | ||
import os | ||
res = subprocess.run(["gh", "api", "/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files", "--paginate"], capture_output=True, check=True) | ||
files = json.loads(res.stdout) | ||
files = [f["filename"] for f in files] | ||
files = [f for f in files if fnmatch.fnmatch(f, '${{ inputs.filter }}')] | ||
with open(os.getenv("GITHUB_OUTPUT"), "a") as output_file: | ||
output_file.write(f"any_changed={'true' if files else 'false'}\n") | ||
output_file.write(f"all_changed_files={' '.join(files)}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters