I'm new to GitHub actions, I want to use PowerShell and save the output of a command to a file in my repository, but I don't know what's the right way to do it.
name: get hash
on: [workflow_dispatch]
jobs:
build:
name: Run Script
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Script
run: ./script.ps1
shell: pwsh
and using get-filehash command I'm trying to learn creating a simple Github workflow that saves the hash of a file to a text file in my repository.
this is the script.ps1 file content
$wc = [System.Net.WebClient]::new()
$pkgurl = 'File on the web'
$FileHashSHA512 = Get-FileHash -Algorithm SHA512 -InputStream ($wc.OpenRead($pkgurl))
$FileHashSHA512.Hash > .\sss.txt
I know it's not practical but I want to learn basics of workflows. the command works on my computer but I just don't get how Github workflows work when it comes to saving files on my repository.
I also want to make this command work in the same workflow:
Invoke-WebRequest -Uri $pkgurl -OutFile .\file.zip
but again don't know how to make the workflow save the file in the repository's root.
since these are very basic, I'm trying to create/write the workflow files myself and not use other people's pre-made actions.