How do I check if a submodule changed commit against the source branch? #2217
-
I'm using this action to get what files have changed when running a CI job. How does one check if the Submodule commit hash itself has changed? My PR has the following change: I have tried this out by setting "exclude_submodules: false" in the action inputs. The submodule itself does not show up in the all_changed_files output. Any help would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
HI @vib-etched, here’s how you can check for changes in a submodule path. name: Check Submodule Changes
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
check-submodule-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history
submodules: true # Ensure submodules are included=
- name: Get changed files including submodules
id: changed-files
uses: tj-actions/changed-files@v44
# No need to set `exclude_submodules` as it defaults to `false`
- name: Check if submodule changed
run: |
echo "${{ steps.changed-files.outputs.all_changed_files }}"
if echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -q 'submodule-path'; then
echo "Submodule has changed."
else
echo "No changes in submodule."
fi |
Beta Was this translation helpful? Give feedback.
-
@vib-etched |
Beta Was this translation helpful? Give feedback.
HI @vib-etched, here’s how you can check for changes in a submodule path.