Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/actions/infrastructure/get-changed-files/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Get Changed Files Action

A reusable composite action that retrieves the list of files changed in a pull request or push event.
A reusable composite action that retrieves the list of files changed in a pull request or push event, or all matching files for scheduled and manual runs.

## Features

- Supports both `pull_request` and `push` events
- Supports `schedule` and `workflow_dispatch` events (returns all matching files)
- Optional filtering by file pattern
- Returns files as JSON array for easy consumption
- Filters out deleted files (only returns added, modified, or renamed files)
Expand Down Expand Up @@ -53,12 +54,26 @@ A reusable composite action that retrieves the list of files changed in a pull r
event-types: 'pull_request,push'
```

### Support Scheduled and Manual Runs

For `schedule` and `workflow_dispatch` events there is no diff to compare, so
the action returns **all** repository files that match the filter.

```yaml
- name: Get all matching files (schedule/dispatch)
id: all-files
uses: "./.github/actions/infrastructure/get-changed-files"
with:
filter: '*.md'
event-types: 'pull_request,push,schedule,workflow_dispatch'
```

## Inputs

| Name | Description | Required | Default |
|------|-------------|----------|---------|
| `filter` | Optional filter pattern (e.g., `*.md` for markdown files, `.github/` for GitHub files) | No | `''` |
| `event-types` | Comma-separated list of event types to support (`pull_request`, `push`) | No | `pull_request` |
| `event-types` | Comma-separated list of event types to support (`pull_request`, `push`, `schedule`, `workflow_dispatch`) | No | `pull_request` |

## Outputs

Expand Down
26 changes: 24 additions & 2 deletions .github/actions/infrastructure/get-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: 'Get Changed Files'
description: 'Gets the list of files changed in a pull request or push event'
description: 'Gets changed files for PR/push events, or all matching files for schedule/dispatch events'
inputs:
filter:
description: 'Optional filter pattern (e.g., "*.md" for markdown files, ".github/" for GitHub files)'
required: false
default: ''
event-types:
description: 'Comma-separated list of event types to support (pull_request, push)'
description: 'Comma-separated list of event types to support (pull_request, push, schedule, workflow_dispatch)'
required: false
default: 'pull_request'
outputs:
Expand Down Expand Up @@ -72,6 +72,28 @@ runs:
.filter(file => file.status === 'added' || file.status === 'modified' || file.status === 'renamed')
.map(file => file.filename);

} else if (
(eventTypes.includes('schedule') && context.eventName === 'schedule') ||
(eventTypes.includes('workflow_dispatch') && context.eventName === 'workflow_dispatch')
) {
const label = context.eventName === 'schedule' ? 'Scheduled' : 'Manual';
console.log(`${label} run: scanning all matching files in repository`);

const { data: tree } = await github.rest.git.getTree({
owner: context.repo.owner,
repo: context.repo.repo,
tree_sha: context.sha,
recursive: 'true',
});

if (tree.truncated) {
core.warning('Repository tree was truncated by the GitHub API. Some files may be missing from the scan.');
}

changedFiles = tree.tree
.filter(item => item.type === 'blob')
.map(item => item.path);

} else {
core.setFailed(`Unsupported event type: ${context.eventName}. Supported types: ${eventTypes.join(', ')}`);
return;
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/infrastructure/markdownlinks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
uses: "./.github/actions/infrastructure/get-changed-files"
with:
filter: '*.md'
event-types: 'pull_request,push'
event-types: 'pull_request,push,schedule,workflow_dispatch'

- name: Verify markdown links
id: verify
Expand Down