In GitHub Actions, can we directly write python code under run |
-section in action.yml
file?
Can I write GitHub Actions scripts in Python?
Asked
Active
Viewed 3,414 times
8
1 Answers
15
There is a built-in shell
keyword for python.
steps:
- name: Display the path
run: |
import os
print(os.environ['PATH'])
shell: python
You can also use a custom shell. GitHub Actions writes the value of run
to a temporary file and passes it to the specified shell by replacing {0}
with the file name of the temporary script.
steps:
- name: Display the path
run: |
import os
print(os.environ['PATH'])
shell: python {0}

riQQ
- 9,878
- 7
- 49
- 66