jannekem / run-python-script-action Goto Github PK
View Code? Open in Web Editor NEWWrite Python scripts in an Actions workflow file
License: MIT License
Write Python scripts in an Actions workflow file
License: MIT License
As of today I can't find anyway to run the script and at the same time pass values via argv[].
It might be key feature to be added to your workflow.
Is it possible to add support for accessing context information, like the github
instance? I need to access data in it that is too large to store in an environment variable and that might contain characters that aren't escaped, so it's really difficult to deal with the data in a shell script (I.e. in run
).
Just an idea that would make run-python-script-action even better.
I think the main use case is to set output or environment variables. run-python-script-action could provide functions to make this easier. You can prepend import gha
to the script (perhaps controlled by an option) which provides these functions:
def set_output(name, value):
print(f'::set-output {name}=stable::{value}')
def set_env(name, value):
with open(os.getenv('GITHUB_ENV'), 'a') as env:
print(f'{name}={value}', file=env)
So then a user could do something like:
- name: Find path to wheel
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
from pathlib import Path
wheel_path = str(next(Path('dist').glob('*.whl')))
gha.set_env('WHEEL_PATH', wheel_path)
Even better would be to also collect all output and environment variables and (optionally) print their names/values to the log, which can help with debugging.
Currently, when the Python script fails, due to an unhandled exception for example, the workflow will continue executing the next step.
Thanks for this useful action!
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: jannekem/run-python-script-action
GitHub started printing this warning on set-output commands:
Warning: The
set-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
You should change the set_output
and save_state
functions in util.py to print to the files pointed to by the GITHUB_OUTPUT
and GITHUB_STATE
environment variables instead of stdout.
getting below error in workflow run
Run actions/setup-python@v[2](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:2)
with:
python-version: [3](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:3).x
token: ***
env:
git_commit_count: 29182
Version 3.x was not found in the local cache
Version 3.x is available for downloading
Download from "https://github.com/actions/python-versions/releases/download/3.10.[4](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:4)-2268648287/python-3.10.4-win32-x64.zip"
Extract downloaded archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\git\_work\_temp\81a0a7f[5](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:5)-be12-44d[6](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:6)-96f6-241b9685fa98', 'C:\git\_work\_temp\3229e638-8a2[7](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:7)-495b-b49d-26a6b41a8d25')"
Execute installation script
Check if Python hostedtoolcache folder exist...
Create Python toolcache folder
Check if current Python version is installed...
No Python3.10.* found
Remove registry entries for Python 3.10(x64)...
Create Python 3.10.4 folder in C:\git\_work\_tool\Python
Copy Python binaries to C:\git\_work\_tool\Python\3.10.4\x64
Install Python 3.10.4 in C:\git\_work\_tool\Python...
Error: Error happened during Python installation
At C:\git\_work\_temp\3229e638-8a2[7](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:8)-495b-b49d-26a6b41a[8](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:9)d25\setup.ps1:[12](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:13)5 char:5
+ Throw "Error happened during Python installation"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: + CategoryInfo : OperationStopped: (Error happened ...on installation:String) [], RuntimeException
+ FullyQualifiedErrorId : Error happened during Python installation
Error: The process 'C:\Windows\System[32](https://github.com/erwin-inc/erwin-main-MCL/runs/6604929896?check_suite_focus=true#step:6:33)\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.