Skip to content

Commit

Permalink
Update pwsh commands (#34253)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Nguyen <150945400+nguyenalex836@users.noreply.github.com>
  • Loading branch information
MrHinsh and nguyenalex836 authored Sep 16, 2024
1 parent 7437529 commit dea8b18
Showing 1 changed file with 19 additions and 19 deletions.
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

0 comments on commit dea8b18

Please sign in to comment.