Skip to content

Commit

Permalink
ci: should_run_monty action explicit inputs (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanls authored Nov 26, 2024
1 parent dec6029 commit f69dd71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .github/actions/should_run_monty/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: "Should Run Monty"
description: "Determines if the Monty workflow should run based on the changed files."

inputs:
git_base_ref:
description: "The git base ref to compare against."
git_sha:
description: "The git sha to compare against."
github_event_name:
description: "The event name."
required: true
working_directory:
description: "The directory to run the command in."
required: true
Expand All @@ -15,20 +22,20 @@ runs:
using: "composite"
steps:
- name: Filter by path for a pull request
if: ${{ github.event_name == 'pull_request' }}
if: ${{ inputs.github_event_name == 'pull_request' }}
id: filter_by_path_pr
working-directory: ${{ inputs.working_directory }}
shell: bash
run: |
git diff --name-only origin/${{ github.base_ref }} > changed_files.txt
git diff --name-only origin/${{ inputs.git_base_ref }} > changed_files.txt
./.github/actions/should_run_monty/check_changed_files.sh
- name: Filter by path for a push
if: ${{ github.event_name == 'push' }}
if: ${{ inputs.github_event_name == 'push' }}
id: filter_by_path_push
working-directory: ${{ inputs.working_directory }}
shell: bash
run: |
git diff --name-only ${{ github.sha }}^1 > changed_files.txt
git diff --name-only ${{ inputs.git_sha }}^1 > changed_files.txt
./.github/actions/should_run_monty/check_changed_files.sh
- name: Should run
id: should_run
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/monty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ jobs:
id: should_run_monty
uses: ./tbp.monty/.github/actions/should_run_monty
with:
git_base_ref: ${{ github.base_ref }}
git_sha: ${{ github.sha }}
github_event_name: ${{ github.event_name }}
working_directory: tbp.monty

test_monty:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/monty_api_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
id: should_run_monty_api_docs
uses: ./tbp.monty/.github/actions/should_run_monty
with:
git_base_ref: ${{ github.event.workflow_run.head_branch }}
git_sha: ${{ github.event.workflow_run.head_sha }}
github_event_name: ${{ github.event.workflow_run.event }}
working_directory: tbp.monty
# Downloading the artifact from the previous run so that actions/deploy-pages can find it.
- name: Download artifact
Expand Down

0 comments on commit f69dd71

Please sign in to comment.