-
Notifications
You must be signed in to change notification settings - Fork 863
79 lines (70 loc) · 2.88 KB
/
cascade-include-changes.yml
File metadata and controls
79 lines (70 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Cascade Include Changes
on:
# Automatic: fires when a PR that touches the includes folder is merged into main.
pull_request:
types: [closed]
branches:
- live
paths:
- "shared/dynamics365-core/**"
# Manual: re-run a cascade when the automatic trigger fails or needs to be retried.
workflow_dispatch:
inputs:
changed_files:
description: >
Space-separated list of include file paths, e.g.
"shared/dynamics365-core/file-a.md shared/dynamics365-core/file-b.md"
required: true
type: string
pr_number:
description: "Source PR number or URL (e.g. 11830 or https://github.com/.../pull/11830)"
required: true
type: string
jobs:
cascade:
# For pull_request events: only run when the PR was actually merged.
# For workflow_dispatch: always run.
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout source repo
uses: actions/checkout@v6
# For automatic runs: fetch the file list from the merged PR.
# For manual runs: use the value typed into the dispatch form.
- name: Resolve changed include files
id: changed
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
FILES="${{ inputs.changed_files }}"
echo "Manual run — using provided file list: $FILES"
else
FILES=$(gh pr view "${{ github.event.pull_request.number }}" \
--json files \
--jq '[.files[].path] | join(" ")')
echo "PR merge — fetched file list: $FILES"
fi
echo "files=$FILES" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.CASCADE_PAT }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
# No third-party deps needed — script uses stdlib only.
- name: Cascade include changes to downstream repos
env:
# CASCADE_PAT must be a classic PAT with repo scope, stored as a
# repository secret in the source (includes) repo.
GITHUB_TOKEN: ${{ secrets.CASCADE_PAT }}
CHANGED_FILES: ${{ steps.changed.outputs.files }}
PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}
PR_URL: ${{ github.event_name == 'workflow_dispatch' && '' || github.event.pull_request.html_url }}
run: python scripts/cascade_dates.py
- name: Post summary comment on source PR
if: github.event_name == 'pull_request' && success()
run: |
gh pr comment "${{ github.event.pull_request.number }}" \
--repo "${{ github.repository }}" \
--body-file cascade-summary.md
env:
GH_TOKEN: ${{ secrets.CASCADE_PAT }}