name: Using Action
# Demonstrate how to list the files that were changed during the most recent push.
# Which can contain 1 or more commits.
# * Manually - it is rather problematic.
# * Using the [changed-files](https://github.com/marketplace/actions/changed-files) action.
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47
# 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: |
echo "$ALL_CHANGED_FILES"
echo "------"
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
name: Manually
on:
push:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
name: Manual
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 6
- name: Changed files
run: |
echo 2
git diff --name-only HEAD~2
echo 5
git diff --name-only HEAD~5
# This will fail because not enough commits
#echo 6
#git diff --name-only HEAD~6