changed-files

changed-files

GitHub Action工具实现高效文件变更追踪

changed-files是一个GitHub Action工具,用于追踪项目中的文件和目录变更。它可以检测相对于目标分支、当前分支或自定义提交的变化,支持pull request、push等多种触发事件。该工具执行迅速,适用于大型仓库,功能包括glob模式文件匹配、JSON输出生成和Git子模块支持等。changed-files为开发者提供了高效的文件变更追踪方案。

GitHub Actions代码变更检测工作流自动化持续集成版本控制Github开源项目

Ubuntu Mac OS Windows Public workflows that use this action.

Codacy Badge CI Update release version.

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END -->

changed-files

Effortlessly track all changed files and directories relative to a target branch, the current branch (preceding commit or the last remote commit), multiple branches, or custom commits returning relative paths from the project root using this GitHub action.

[!NOTE]

Table of contents

Features 🚀

  • Fast execution, averaging 0-10 seconds.
  • Leverages either Github's REST API or Git's native diff to determine changed files.
  • Facilitates easy debugging.
  • Scales to handle large/mono repositories.
  • Supports Git submodules.
  • Supports merge queues for pull requests.
  • Generates escaped JSON output for running matrix jobs based on changed files.
  • Lists changed directories.
    • Limits matching changed directories to a specified maximum depth.
    • Optionally excludes the current directory.
  • Writes outputs to a designated .txt or .json file for further processing.
  • Restores deleted files to their previous location or a newly specified location.
  • Supports fetching a fixed number of commits which improves performance.
  • Compatible with all platforms (Linux, MacOS, Windows).
  • Supports GitHub-hosted runners.
  • Supports GitHub Enterprise Server.
  • Supports self-hosted runners.
  • Lists all files and directories that have changed:
    • Between the current pull request branch and the last commit on the target branch.
    • Between the last commit and the current pushed change.
    • Between the last remote branch commit and the current HEAD.
  • Restricts change detection to a subset of files and directories:

And many more...

Usage 💻

[!IMPORTANT]

  • Push Events: When configuring actions/checkout, make sure to set fetch-depth to either 0 or 2, depending on your use case.
  • Mono Repositories: To avoid pulling the entire branch history, you can utilize the default actions/checkout's fetch-depth of 1 for pull_request events.
  • Quoting Multiline Inputs: Avoid using single or double quotes for multiline inputs. The value is already a string separated by a newline character. Refer to the Examples section for more information.
  • Credentials Persistence: If fetch-depth is not set to 0, make sure to set persist-credentials to true when configuring actions/checkout.
  • Matching Files and Folders: To match all files and folders under a directory, this requires a globstar pattern e.g. dir_name/** which matches any number of subdirectories and files.

Visit the discussions for more information or create a new discussion for usage-related questions.

On pull_request 🔀

Detect changes to all files in a Pull request relative to the target branch or since the last pushed commit.

Using local .git directory 📁

name: CI on: pull_request: branches: - main jobs: # ------------------------------------------------------------------------------------------------------------------------------------------------ # Event `pull_request`: Compare the last commit of the main branch or last remote commit of the PR branch -> to the current commit of a PR branch. # ------------------------------------------------------------------------------------------------------------------------------------------------ changed_files: runs-on: ubuntu-latest # windows-latest || macos-latest name: Test changed-files steps: - uses: actions/checkout@v4 # ----------------------------------------------------------------------------------------------------------- # Example 1 # ----------------------------------------------------------------------------------------------------------- - name: Get changed files id: changed-files uses: tj-actions/changed-files@v44 # To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g # with: # since_last_remote_commit: true - name: List all changed files env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | for file in ${ALL_CHANGED_FILES}; do echo "$file was changed" done # ----------------------------------------------------------------------------------------------------------- # Example 2 # ----------------------------------------------------------------------------------------------------------- - name: Get all changed markdown files id: changed-markdown-files uses: tj-actions/changed-files@v44 with: # Avoid using single or double quotes for multiline patterns files: | **.md - name: List all changed files markdown files if: steps.changed-markdown-files.outputs.any_changed == 'true' env: ALL_CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }} run: | for file in ${ALL_CHANGED_FILES}; do echo "$file was changed" done # ----------------------------------------------------------------------------------------------------------- # Example 3 # ----------------------------------------------------------------------------------------------------------- - name: Get all test, doc and src files that have changed id: changed-files-yaml uses: tj-actions/changed-files@v44 with: files_yaml: | doc: - '**.md' - docs/** test: - test/** - '!test/**.md' src: - src/** # Optionally set `files_yaml_from_source_file` to read the YAML from a file. e.g `files_yaml_from_source_file: .github/changed-files.yml` - name: Run step if test file(s) change # NOTE: Ensure all outputs are prefixed by the same key used above e.g. `test_(...)` | `doc_(...)` | `src_(...)` when trying to access the `any_changed` output. if: steps.changed-files-yaml.outputs.test_any_changed == 'true' env: TEST_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.test_all_changed_files }} run: | echo "One or more test file(s) has changed." echo "List all the files that have changed: $TEST_ALL_CHANGED_FILES" - name: Run step if doc file(s) change if: steps.changed-files-yaml.outputs.doc_any_changed == 'true' env: DOC_ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.doc_all_changed_files }} run: | echo "One or more doc file(s) has changed." echo "List all the files that have changed: $DOC_ALL_CHANGED_FILES" # ----------------------------------------------------------------------------------------------------------- # Example 4 # ----------------------------------------------------------------------------------------------------------- - name: Get changed files in the docs folder id: changed-files-specific uses: tj-actions/changed-files@v44 with: files: docs/*.{js,html} # Alternatively using: `docs/**` files_ignore: docs/static.js - name: Run step if any file(s) in the docs folder change if: steps.changed-files-specific.outputs.any_changed == 'true' env: ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }} run: | echo "One or more files in the docs folder has changed." echo "List all the files that have changed: $ALL_CHANGED_FILES"

Using Github's API :octocat:

name: CI on: pull_request: branches: - main jobs: # ------------------------------------------------------------- # Event `pull_request`: Returns all changed pull request files. # -------------------------------------------------------------- changed_files: # NOTE: # - This is limited to pull_request* events and would raise an error for other events. # - A maximum of 3000 files can be returned. # - For more flexibility and no limitations see "Using local .git directory" above. runs-on: ubuntu-latest # windows-latest || macos-latest name: Test changed-files permissions: pull-requests: read steps: - name: Get changed files id: changed-files uses: tj-actions/changed-files@v44 - name: List all changed files env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | for file in ${ALL_CHANGED_FILES}; do echo "$file was changed" done

On push ⬆️

Detect changes to files made since the last pushed commit.

name: CI on: push: branches: - main jobs: # ------------------------------------------------------------- # Using GitHub's API is not supported for push events # ------------------------------------------------------------- # # ---------------------------------------------------------------------------------------------- # Using local .git history # ---------------------------------------------------------------------------------------------- # Event `push`: Compare the preceding remote commit -> to the current commit of the main branch # ---------------------------------------------------------------------------------------------- changed_files: runs-on: ubuntu-latest # windows-latest || macos-latest name: Test changed-files steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - name: Get changed files id: changed-files uses: tj-actions/changed-files@v44 # NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit. - name: List all changed files env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | for file in ${ALL_CHANGED_FILES}; do echo "$file was changed" done ...

Other supported events :electron:

To access more examples, navigate to the Examples section.

If you feel generous and want to show some extra appreciation:

Support this project with a :star:

Buy me a coffee

[!IMPORTANT]

  • When using files_yaml* inputs:
    • All keys must start with a letter or _ and contain only alphanumeric characters, -, or _.

      For example, test or test_key or test-key or _test_key are all valid choices.

Inputs ⚙️

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
- uses: tj-actions/changed-files@v44 id: changed-files with: # Github API URL. # Type: string # Default: "${{ github.api_url }}" api_url: '' # Specify a different base commit # SHA or branch used for # comparing changes # Type: string base_sha: '' # Exclude changes outside the current # directory and show path names # relative to it. NOTE: This # requires you to specify the # top-level directory via the `path` # input. # Type: boolean # Default: "true" diff_relative: ''

编辑推荐精选

Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

openai-agents-python

openai-agents-python

OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。

openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。

Hunyuan3D-2

Hunyuan3D-2

高分辨率纹理 3D 资产生成

Hunyuan3D-2 是腾讯开发的用于 3D 资产生成的强大工具,支持从文本描述、单张图片或多视角图片生成 3D 模型,具备快速形状生成能力,可生成带纹理的高质量 3D 模型,适用于多个领域,为 3D 创作提供了高效解决方案。

3FS

3FS

一个具备存储、管理和客户端操作等多种功能的分布式文件系统相关项目。

3FS 是一个功能强大的分布式文件系统项目,涵盖了存储引擎、元数据管理、客户端工具等多个模块。它支持多种文件操作,如创建文件和目录、设置布局等,同时具备高效的事件循环、节点选择和协程池管理等特性。适用于需要大规模数据存储和管理的场景,能够提高系统的性能和可靠性,是分布式存储领域的优质解决方案。

TRELLIS

TRELLIS

用于可扩展和多功能 3D 生成的结构化 3D 潜在表示

TRELLIS 是一个专注于 3D 生成的项目,它利用结构化 3D 潜在表示技术,实现了可扩展且多功能的 3D 生成。项目提供了多种 3D 生成的方法和工具,包括文本到 3D、图像到 3D 等,并且支持多种输出格式,如 3D 高斯、辐射场和网格等。通过 TRELLIS,用户可以根据文本描述或图像输入快速生成高质量的 3D 资产,适用于游戏开发、动画制作、虚拟现实等多个领域。

ai-agents-for-beginners

ai-agents-for-beginners

10 节课教你开启构建 AI 代理所需的一切知识

AI Agents for Beginners 是一个专为初学者打造的课程项目,提供 10 节课程,涵盖构建 AI 代理的必备知识,支持多种语言,包含规划设计、工具使用、多代理等丰富内容,助您快速入门 AI 代理领域。

下拉加载更多