Skip to content

Commit

Permalink
pythongh-122965: Fix reusable-change-detection.yml on `workflow_dis…
Browse files Browse the repository at this point in the history
…patch` (python#122966)
  • Loading branch information
sobolevn authored and blhsing committed Aug 22, 2024
1 parent f8830e3 commit 36c5102
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/reusable-change-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,18 @@ jobs:
.github/workflows/reusable-docs.yml
format: csv # works for paths with spaces
- name: Check for docs changes
# We only want to run this on PRs when related files are changed,
# or when user triggers manual workflow run.
if: >-
github.event_name == 'pull_request'
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
(
github.event_name == 'pull_request'
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
) || github.event_name == 'workflow_dispatch'
id: docs-changes
run: |
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
- name: Get a list of the MSI installer-related files
if: github.event_name == 'pull_request'
id: changed-win-msi-files
uses: Ana06/get-changed-files@v2.3.0
with:
Expand All @@ -141,10 +146,13 @@ jobs:
.github/workflows/reusable-windows-msi.yml
format: csv # works for paths with spaces
- name: Check for changes in MSI installer-related files
# We only want to run this on PRs when related files are changed,
# or when user triggers manual workflow run.
if: >-
steps.changed-win-msi-files.outputs.added_modified_renamed != ''
(
github.event_name == 'pull_request'
&& steps.changed-win-msi-files.outputs.added_modified_renamed != ''
) || github.event_name == 'workflow_dispatch'
id: win-msi-changes
run: |
echo "run-win-msi=true" >> "${GITHUB_OUTPUT}"
...
8 changes: 7 additions & 1 deletion .github/workflows/reusable-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ jobs:
- name: 'Check out latest PR branch commit'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
ref: >-
${{
github.event_name == 'pull_request'
&& github.event.pull_request.head.sha
|| ''
}}
# Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
- name: 'Fetch commits to get branch diff'
if: github.event_name == 'pull_request'
run: |
# Fetch enough history to find a common ancestor commit (aka merge-base):
git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \
Expand Down

0 comments on commit 36c5102

Please sign in to comment.