forked from conan-io/conan-center-index
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eric's new "files matched" action (#41)
* github actions: don't use tj-actions/changed-files avoids all its bugs alltogether eg tj-actions/changed-files#704 * fix forks * add github token * don't use PurePath.is_relative_to * fixup * add yml error * add conanfile.py error * add test error * touch linter * use fnmatch * fxup * use a dedicated action * Update config.yml * Update conanfile.py * Update conanfile.py * Update conanv2_transition.py Co-authored-by: ericLemanissier <ericLemanissier@users.noreply.github.com>
- Loading branch information
1 parent
24274d8
commit 46bbd46
Showing
3 changed files
with
44 additions
and
18 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: | ||
files: | ||
description: "Check for changes using only this list of files (Defaults to the entire repo)" | ||
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: ${{ 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.files }}'''.strip())] | ||
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