Feature request, ability to run python file
Description
Ability to specify a file to run instead of the pure python script
Example:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: jannekem/run-python-script-action@v1
with:
file: path/to/script.py
Seggestion
- [ ] Ability to run python file
- [ ] Ability to run python files on a specific branch
Why would you need an action to run a Python script when you can already do so with the run keyword?
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: python3 path/to/script.py
I tried to use the run command but apparently it would seem to run the file only on the branch master, even if previously it was the checkout of the branch target.
For example, my Python file performs changes to project files, and my goal is to commission these modified files in the destination branch
My action steps
- name: Checkout repo content
uses: actions/checkout@v3 # checkout the repository content to GitHub runner
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.10" # install the python version needed
- name: Install python packages
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Execute py script
run: python3 path/to/script.py
- name: Check diff
uses: technote-space/get-diff-action@v6
with:
FILES: |
target_file.txt
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "bot: Update file" -a
if: env.GIT_DIFF && env.MATCHED_FILES
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
if: env.GIT_DIFF && env.MATCHED_FILES
In Check diff step no file was found changed
Why would you need an action to run a Python script when you can already do so with the run keyword?
That doesn't inject utility functions for interacting with the workflow like run-python-script-action does, does it?
No, you would need to use workflow commands in the same fashion as this action does: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions
The idea of the action is to be able to define your Python script inline in the YAML. The requested feature already exists in GitHub workflows via the standard run command, which allows users to execute Python files directly without requiring a specific action. The purpose of this action is to address different use cases, and running Python scripts is fully supported out-of-the-box by GitHub workflows. For these reasons, I'll be closing this issue.