-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent unintended input replacement in reusable workflows with …
…workflow_dispatch when using workflow_call (#2502) * Remove redundant check See: #2464 (comment) * Add condition to prevent replacing inputs in reusable workflows with workflow_dispatch inputs Closes: #2464 * fmt * Revert "Remove redundant check" This reverts commit 6345596. * add test * Update runner_test.go * update label --------- Co-authored-by: ChristopherHX <[email protected]>
- Loading branch information
1 parent
bd8dda1
commit deea8ec
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
pkg/runner/testdata/.github/workflows/local-reusable-and-dispatch.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: reuse | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
my-val: | ||
type: string | ||
required: true | ||
default: "default_value_reuse_workflow_dispatch_call" | ||
dispatch-val: | ||
type: string | ||
default: "I am a dispatch var for checking if I am being used in workflow_call" | ||
|
||
workflow_call: | ||
inputs: | ||
my-val: | ||
type: string | ||
required: true | ||
default: "default_value_reuse_workflow_call" | ||
|
||
jobs: | ||
reusable_workflow_job: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run a one-line script | ||
run: echo "✅ 🚀 ✅ hello this is from workflow reuse. Value - " ${{ inputs.my-val }} ${{ github.event_name }} ${{ inputs.dispatch-val }} | ||
- name: Assert | ||
run: | | ||
exit ${{ ( inputs.my-val == 'default_value_reuse_workflow_call' || inputs.my-val == 'passed value from main' ) && !inputs.dispatch-val && '0' || '1' }} |
21 changes: 21 additions & 0 deletions
21
pkg/runner/testdata/uses-workflow-defaults/workflow_dispatch.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run a one-line script | ||
run: echo "✅ 🚀 ✅ hello this is from workflow main" ${{ github.event_name }} | ||
call-reuse-w-val: | ||
uses: ./.github/workflows/local-reusable-and-dispatch.yml | ||
with: | ||
my-val: "passed value from main" |