In GitHub Action workflows, there is no direct way to repeat the same job or step using variables. We have to use the "matrix" to achieve this.
Example:
my_loop_job:
name: loop job
runs-on: my-github-runners
strategy:
matrix:
my_variable: [ "var1", "var2", "var3" ]
steps:
- name: test loop
run: |
echo "running the steps for $my_variable"
sh myscript.sh $
When using strategy matrix, it will create parallel jobs using the variables passed. Maximum jobs matrix can create is 256 Jobs.