Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
name: 'Usage of changed-files GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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
changed-files
:octocat: Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
What is changed-files?β
You can easily keep track of all changed (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories relative to a target branch, current branch, preceding commit, or last remote commit, multiple branches, or custom commitsβall returning relative paths from the project root, using this GitHub action.
How to Define a Base Commit for Comparison?β
Set the base_sha
to specify a commit SHA or branch for comparing changes.
- uses: tj-actions/changed-files@v44
with:
base_sha: 'main'
How to Make Path Differences Relativeβ
Use the diff_relative
boolean to make path differences relative to a specified directory.
- uses: tj-actions/changed-files@v44
with:
diff_relative: true
How to Output Unique Changed Directories?β
Enable the dir_names
input to output unique directory names instead of filenames.
- uses: tj-actions/changed-files@v44
with:
dir_names: true
How to Include Only Deleted Directories?β
Set dir_names_deleted_files_include_only_deleted_dirs
to true to include only directories that have been deleted.
- uses: tj-actions/changed-files@v44
with:
dir_names_deleted_files_include_only_deleted_dirs: true
How to Exclude the Current Directory from Outputs?β
Activate the dir_names_exclude_current_dir
to exclude the current directory represented by . from outputs.
- uses: tj-actions/changed-files@v44
with:
dir_names_exclude_current_dir: true
How to Include Specific File Patterns in Directory Outputs?β
Specify dir_names_include_files
to include certain file patterns when dir_names is set to true.
- uses: tj-actions/changed-files@v44
with:
dir_names_include_files: 'src/**/*.py'
How to Include Specific File Patterns in Directory Outputs?β
Specify dir_names_include_files
to include certain file patterns when dir_names is set to true.
- uses: tj-actions/changed-files@v44
with:
dir_names_include_files: 'src/**/*.py'
How to Limit Directory Output Depth?β
Limit the depth of directory outputs. Useful for large repositories where changes are nested in deep directory structures.
- uses: tj-actions/changed-files@v44
with:
dir_names_max_depth: '2'
How to Escape JSON Output?β
Control JSON output escaping, useful when outputs are used in subsequent steps that parse JSON.
- uses: tj-actions/changed-files@v44
with:
escape_json: true
How to Exclude Submodule Changes?β
Exclude changes to submodules from the action's output, which can be essential for repositories with many submodules.
- uses: tj-actions/changed-files@v44
with:
exclude_submodules: false
How to Handle Failures on Initial Diff?β
Define the action's behavior when the initial diff calculation fails.
- uses: tj-actions/changed-files@v44
with:
fail_on_initial_diff_error: false
How to Handle Failures on Submodule Diff?β
Set up error handling for submodule diffs specifically.
- uses: tj-actions/changed-files@v44
with:
fail_on_submodule_diff_error: false
How to Fetch Additional Submodule History?β
Fetch more history for submodules to ensure a comprehensive diff.
- uses: tj-actions/changed-files@v44
with:
fetch_additional_submodule_history: false
How to Set the Depth of History Fetched?β
Specify how much branch history to fetch, which can help resolve issues with insufficient history.
- uses: tj-actions/changed-files@v44
with:
fetch_depth: '25'