Skip to content

Update pwsh commands #34253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ jobs:
steps:
- shell: pwsh
run: |
"mypath" | Out-File -FilePath $env:GITHUB_PATH -Append
"mypath" >> $env:GITHUB_PATH
```

{% endnote %}
Expand All @@ -652,7 +652,7 @@ echo "{environment_variable_name}={value}" >> "$GITHUB_ENV"
* Using PowerShell version 6 and higher:

```powershell copy
"{environment_variable_name}={value}" | Out-File -FilePath $env:GITHUB_ENV -Append
"{environment_variable_name}={value}" >> $env:GITHUB_ENV
```

* Using PowerShell version 5.1 and below:
Expand Down Expand Up @@ -698,7 +698,7 @@ steps:
- name: Set the value
id: step_one
run: |
"action_state=yellow" | Out-File -FilePath $env:GITHUB_ENV -Append
"action_state=yellow" >> $env:GITHUB_ENV
- name: Use the value
id: step_two
run: |
Expand Down Expand Up @@ -750,10 +750,10 @@ steps:
- name: Set the value in pwsh
id: step_one
run: |
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)})
"JSON_RESPONSE<<$EOF" | Out-File -FilePath $env:GITHUB_ENV -Append
(Invoke-WebRequest -Uri "https://example.com").Content | Out-File -FilePath $env:GITHUB_ENV -Append
"$EOF" | Out-File -FilePath $env:GITHUB_ENV -Append
$EOF = (New-Guid).Guid
"JSON_RESPONSE<<$EOF" >> $env:GITHUB_ENV
(Invoke-WebRequest -Uri "https://example.com").Content >> $env:GITHUB_ENV
"$EOF" >> $env:GITHUB_ENV
shell: pwsh
```

Expand All @@ -774,7 +774,7 @@ echo "{name}={value}" >> "$GITHUB_OUTPUT"
{% powershell %}

```powershell copy
"{name}=value" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"{name}=value" >> $env:GITHUB_OUTPUT
```

{% endpowershell %}
Expand Down Expand Up @@ -805,7 +805,7 @@ This example demonstrates how to set the `SELECTED_COLOR` output parameter and l
- name: Set color
id: color-selector
run: |
"SELECTED_COLOR=green" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"SELECTED_COLOR=green" >> $env:GITHUB_OUTPUT
- name: Get color
env:{% raw %}
SELECTED_COLOR: ${{ steps.color-selector.outputs.SELECTED_COLOR }}{% endraw %}
Expand All @@ -827,7 +827,7 @@ echo "{markdown content}" >> $GITHUB_STEP_SUMMARY
{% powershell %}

```powershell copy
"{markdown content}" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"{markdown content}" >> $env:GITHUB_STEP_SUMMARY
```

{% endpowershell %}
Expand All @@ -851,7 +851,7 @@ echo "### Hello world! :rocket:" >> $GITHUB_STEP_SUMMARY
{% powershell %}

```powershell copy
"### Hello world! :rocket:" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"### Hello world! :rocket:" >> $env:GITHUB_STEP_SUMMARY
```

{% endpowershell %}
Expand Down Expand Up @@ -883,11 +883,11 @@ For multiline Markdown content, you can use `>>` to continuously append content
```yaml
- name: Generate list using Markdown
run: |
"This is the lead in sentence for the list" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append # this is a blank line
"- Lets add a bullet point" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"- Lets add a second bullet point" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"- How about a third one?" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"This is the lead in sentence for the list" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY # this is a blank line
"- Lets add a bullet point" >> $env:GITHUB_STEP_SUMMARY
"- Lets add a second bullet point" >> $env:GITHUB_STEP_SUMMARY
"- How about a third one?" >> $env:GITHUB_STEP_SUMMARY
```

{% endpowershell %}
Expand All @@ -914,8 +914,8 @@ To clear all content for the current step, you can use `>` to overwrite any prev
```yaml
- name: Overwrite Markdown
run: |
"Adding some Markdown content" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"There was an error, we need to clear the previous Markdown with some new content." | Out-File -FilePath $env:GITHUB_STEP_SUMMARY
"Adding some Markdown content" >> $env:GITHUB_STEP_SUMMARY
"There was an error, we need to clear the previous Markdown with some new content." >> $env:GITHUB_STEP_SUMMARY
```

{% endpowershell %}
Expand All @@ -942,7 +942,7 @@ To completely remove a summary for the current step, the file that `GITHUB_STEP_
```yaml
- name: Delete all summary content
run: |
"Adding Markdown content that we want to remove before the step ends" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"Adding Markdown content that we want to remove before the step ends" >> $env:GITHUB_STEP_SUMMARY
Remove-Item $env:GITHUB_STEP_SUMMARY
```

Expand Down