Saichovsky
02/14/2024, 8:58 PMjobs:
pop-values-from-list:
runs-on: my-runner
env:
MY_LIST: '[1,2,3,4,5,6,7,8,9,0]' # list has 10 items
steps:
- name: Pop 10% of list
run: |
pop_my_list() {
percentage=$1
list=$2
MY_LIST=$(process_and_pop $percentage $list) >>"$GITHUB_OUTPUT"
}
pop_my_list 10% $MY_LIST # MY_LIST now has 9 items
- run: WaitForAsyncProcess
- name: Pop 20% of list
run: |
pop_my_list() {
percentage=$1
list=$2
MY_LIST=$(process_and_pop $percentage $list) >>"$GITHUB_OUTPUT"
}
pop_my_list 20% $MY_LIST # let's assume that MY_LIST now has 7 items
- run: WaitForAsyncProcess
...
- name: Pop everything that remains in list
...
This is of course a simplified version of what I am trying to achieve. The problem here is that I have to keep repeating the function definition for pop_my_list()
Is there a way I can have the function defined once and invoke it across steps without repetition?Saichovsky
02/14/2024, 9:41 PM$ symbols) in the first step, then sourced the file in subsequent steps before calling the functionIgor Rodionov
02/15/2024, 2:15 PMmanagedkaos
02/16/2024, 4:12 AM