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'
Monitoring GitHub Actions Workflows
CICube is a GitHub Actions monitoring tool that provides you with detailed insights into your workflows to further optimize your CI/CD pipeline. With CICube, you will be able to track your workflow runs, understand where the bottlenecks are, and tease out the best from your build times. Go to cicube.io now and create a free account to better optimize your GitHub Actions workflows!