amadevus / pwsh-script Goto Github PK
View Code? Open in Web Editor NEWGitHub Action to run PowerShell scripts in a rich, prepared scope - inspired by actions/github-script.
License: MIT License
GitHub Action to run PowerShell scripts in a rich, prepared scope - inspired by actions/github-script.
License: MIT License
Hi! First of all thanks for sharing this action!
I'm calling a powershell script like this:
- name: Deploy to Umbraco Cloud
uses: Amadevus/[email protected]
env:
GIT_ADDRESS: ${{ secrets.GIT_ADDRESS }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}
with:
script: . ".\$env:DEPLOY_SCRIPT" -cloneurl "$env:GIT_ADDRESS" -uaasuser "$env:GIT_USERNAME" -password "$env:GIT_PASSWORD" -sourcepath "$env:PUBLISH_DIR" -destinationpath "$env:CLONE_DIR"
The script is running fine, these are the final lines in the script:
Write-Host "Deployment finished"
Write-Verbose "Leaving script DeployToUmbracoCloud.ps1"
I can see the Deployment finished echo in the logs, but the action isn't finishing, it keeps running forever.
How can I make sure the process finished?
Please, help me with pwsh-script action:
https://github.com/test-st-petersburg/DocTemplates/runs/2487220589?check_suite_focus=true#step:4:70
Code:
pwsh-script/lib/GitHubActionsCore/GitHubActionsCore.psm1
Lines 654 to 678 in f755502
One thing I found myself always prepending to all my GitHub action PowerShell script is setting $ProgressPreference
and $InformationPreference
.
$ProgressPreference
to 'Silent'
, because on the GitHub action log PowerShell cannot draw an interactive progress bar and it otherwise causes mangled output$InformationPreference
to 'SilentlyContinue'
(instead of default 'Silent'
) because in GitHub actions you usually want to be able to log text with Write-Information
(and the pipeline output is used as the action output). And can be a bit of a debugging pitfall to realize that Write-Information
is swallowed).What do you think about adding these two lines to the action itself so they don't have to be added manually? I think it would improve the developer experience and not be harmful (and worse case it can be overridden by the user)
Happy to do a PR.
Hi,
The Set-ActionOutput
cmdlet seems to not be working for me at all. I have this workflow, and when it gets to the next step the output isn't even there.
name: Test
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set output
id: test
uses: Amadevus/pwsh-script@v2
with:
script: |
Set-ActionOutput testout igottest
- name: Run a multi-line script
run: |
echo "${{ steps.test.outputs.testout }}"
Thanks for the github action by the way, it's really cool to be able to have all these integrations from within powershell ๐
Setting output fails when using environment files and passing a multi-line value.
https://github.com/Amadevus/pwsh-script/actions/runs/3276636531/jobs/5392922719#step:11:13
Error: Unable to process file command 'output' successfully.
Error: Invalid format ' new line '
Within GitHubActionsCore
PowerShell module we're currently missing some commands and options added since last release:
notice
commandgetState
and saveState
commandssummary
commands (job/step summary)Hi,
I need to run some PowerShell commands as an admin. Is this possible? We're running on our own Github Actions Runners.
Kind regards,
Martin
Please consider publishing the GitHubActionsCore
module in the PowerShell Gallery, so it's available outside of this action. That way, one may utilize Get-ActionInput
and Set-ActionOutput
too.
Hi!
When I run action and when the Run Amadevus/pwsh-script@v2 executes - there is an Error
Error: Invoke-Expression : Cannot bind argument to parameter 'Path' because it is null.
At /home/runner/work/_actions/Amadevus/pwsh-script/v2/action.ps1:21 char:23
$Private:result = Invoke-Expression $Private:scriptFile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidData: (:) [Invoke-Expression], ParameterBindingValidationException
FullyQualifiedErrorId : >ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.InvokeExpressionCommandError: Process completed with exit code 1.
Here is the Action yaml:
`
name: Convert Contact List
on:
workflow_dispatch:
schedule:
- cron: "* */3 * * *"
jobs:
build:
name: Run Script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Amadevus/pwsh-script@v2
id: script
env:
GH_TOKEN: ${{ github.token }}
with:
script: |
# ------ AnyTone ------ #
$DMRIdsContent = Get-Content ./DMRIds.dat
- name: Update files in repository
uses: actions-x/commit@v6
with:
email: "[email protected]"
name: GitHub Actions Autocommitter
branch: master
files: Devices_Contact_List/*
repository: https://github.com/${{ github.repository }}
token: ${{ github.token }}
force: true
`
GitHub changed the way the save-state
and set-output
commands work - instead of console/log output parsing, they're now set through "environment" files.
There's a slash-command available to try out the action. Simply comment on this issue with /demo
in the first line and a PowerShell script in the following lines. If your comment will contain a code-block (fenced or not), contents of it will be executed instead of whole comment body - and it'll look better! :)
For example, comment with:
/demo
```powershell
return (1 + 1)
```
You should get a result (and/or an error) in a comment that will follow.
โน Please note, for security
$github.token
is not available in the demo script. It's available all right in normal action executions. :)
Any plan of including the Az Module by default in a future release?
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.