This action checks for renamed files between two git refs.
Lots! I whipped this up to solve a specific use case in mind for checking if database migrations files on a PR were renamed from or older than on the main branch, but it wouldn't take much to adapt it for more generic cases - mostly some additional parasitisation of filters / regexes for file names.
- For checkFileNameDates to work, the dates in the filenames much be of format VYYYY.MM.DD.NNNN__string, e.g. V2019.01.01.0000__some_string.sql
head
: The first ref to check (defaults to origin/main).feature
: The second ref to check, usually the branch you're running this from (defaults to dev, recommended to use ${{ github.head_ref }}).path
: The path to the file to check (defaults to working directory).similarity
: The similarity threshold to use when comparing files, is treated as a percentage (defaults to 50).diffFilter
: The git diff filter to use when comparing files (R|M|A|C|D|T|U|X|B|*), defaults to RAM (renamed, added, modified).checkFileNameDates
: Enables checking of dates in file names with the format VYYYY.MM.DD.NNNN (e.g. V2022.02.02.2024)debug
: Whether to output debug information (true|false).
modifiedFiles
: An array of files that were renamed between the two refs.
name: Check for renamed files
on:
pull_request:
branches:
- main
jobs:
check-renamed-files:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: sammcj/check-renamed-files-action@main
with:
head: 'origin/main'
feature: ${{ github.head_ref }}
path: src/main/resources/db/migration
similarity: 50
diffFilter: RAM
checkFileNameDates: false
debug: false
This Action uses standard git diff filters.
Any combination of the filter characters (including none) can be used.
When *
(All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.
A
- AddedC
- CopiedD
- DeletedM
- ModifiedR
- RenamedT
- Type change (i.e. regular file, symlink, submodule, …)U
- UnmergedX
- UnknownB
- Broken symbolic link (pairing broken)