Merge pull request #11842 from kristof-mattei/update-powershell-usage
update powershell usage
This commit is contained in:
@@ -13,7 +13,7 @@ authors:
|
||||
type: tutorial
|
||||
topics:
|
||||
- CI
|
||||
- Powershell
|
||||
- PowerShell
|
||||
shortTitle: Build & test PowerShell
|
||||
---
|
||||
|
||||
|
||||
@@ -272,13 +272,33 @@ During the execution of a workflow, the runner generates temporary files that ca
|
||||
|
||||
{% warning %}
|
||||
|
||||
**Warning:** Powershell does not use UTF-8 by default. Make sure you write files using the correct encoding. For example, you need to set UTF-8 encoding when you set the path:
|
||||
**Warning:** On Windows, legacy PowerShell (`shell: powershell`) does not use UTF-8 by default. Make sure you write files using the correct encoding. For example, you need to set UTF-8 encoding when you set the path:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- run: echo "mypath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
jobs:
|
||||
legacy-powershell-example:
|
||||
uses: windows-2019
|
||||
steps:
|
||||
- shell: powershell
|
||||
run: echo "mypath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
```
|
||||
|
||||
Or switch to PowerShell Core, which defaults to UTF-8:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
modern-pwsh-example:
|
||||
uses: windows-2019
|
||||
steps:
|
||||
- shell: pwsh
|
||||
run: echo "mypath" | Out-File -FilePath $env:GITHUB_PATH -Append # no need for -Encoding utf8
|
||||
```
|
||||
|
||||
More detail about UTF-8 and PowerShell Core found on this great [Stack Overflow answer](https://stackoverflow.com/a/40098904/162694):
|
||||
|
||||
> ### Optional reading: The cross-platform perspective: PowerShell _Core_:
|
||||
> [PowerShell is now cross-platform](https://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/), via its **[PowerShell _Core_](https://github.com/PowerShell/PowerShell)** edition, whose encoding - sensibly - **defaults to *BOM-less UTF-8***, in line with Unix-like platforms.
|
||||
|
||||
{% endwarning %}
|
||||
|
||||
## Setting an environment variable
|
||||
|
||||
@@ -235,7 +235,7 @@ If you’re using a phased approach to roll out GHAS, we recommend enabling {% d
|
||||
|
||||
If you’re not planning on a phased rollout approach and want to enable code scanning for many repositories, you may want to script the process.
|
||||
|
||||
For an example of a script that opens pull requests to add a {% data variables.product.prodname_actions %} workflow to multiple repositories, see the [`jhutchings1/Create-ActionsPRs`](https://github.com/jhutchings1/Create-ActionsPRs) repository for an example using Powershell, or [`nickliffen/ghas-enablement`](https://github.com/NickLiffen/ghas-enablement) for teams who do not have Powershell and instead would like to use NodeJS.
|
||||
For an example of a script that opens pull requests to add a {% data variables.product.prodname_actions %} workflow to multiple repositories, see the [`jhutchings1/Create-ActionsPRs`](https://github.com/jhutchings1/Create-ActionsPRs) repository for an example using PowerShell, or [`nickliffen/ghas-enablement`](https://github.com/NickLiffen/ghas-enablement) for teams who do not have PowerShell and instead would like to use NodeJS.
|
||||
|
||||
### Step 4: Run code scans and review your results
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ In rare circumstances, images that are processed through Camo might not appear o
|
||||
|
||||
{% tip %}
|
||||
|
||||
Windows users will either need to use the Git Powershell (which is installed alongside [{% data variables.product.prodname_desktop %}](https://desktop.github.com/)) or download [curl for Windows](http://curl.haxx.se/download.html).
|
||||
Windows users will either need to use the Git PowerShell (which is installed alongside [{% data variables.product.prodname_desktop %}](https://desktop.github.com/)) or download [curl for Windows](http://curl.haxx.se/download.html).
|
||||
|
||||
{% endtip %}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ In the default {% data variables.product.prodname_codeql_workflow %}, {% data va
|
||||
The `on:pull_request` and `on:push` triggers for code scanning are each useful for different purposes. For more information, see "[Scanning pull requests](/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#scanning-pull-requests)" and "[Scanning on push](/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#scanning-on-push)."
|
||||
## Bulk set up of {% data variables.product.prodname_code_scanning %}
|
||||
|
||||
You can set up {% data variables.product.prodname_code_scanning %} in many repositories at once using a script. If you'd like to use a script to raise pull requests that add a {% data variables.product.prodname_actions %} workflow to multiple repositories, see the [`jhutchings1/Create-ActionsPRs`](https://github.com/jhutchings1/Create-ActionsPRs) repository for an example using Powershell, or [`nickliffen/ghas-enablement`](https://github.com/NickLiffen/ghas-enablement) for teams who do not have Powershell and instead would like to use NodeJS.
|
||||
You can set up {% data variables.product.prodname_code_scanning %} in many repositories at once using a script. If you'd like to use a script to raise pull requests that add a {% data variables.product.prodname_actions %} workflow to multiple repositories, see the [`jhutchings1/Create-ActionsPRs`](https://github.com/jhutchings1/Create-ActionsPRs) repository for an example using PowerShell, or [`nickliffen/ghas-enablement`](https://github.com/NickLiffen/ghas-enablement) for teams who do not have PowerShell and instead would like to use NodeJS.
|
||||
|
||||
## Viewing the logging output from {% data variables.product.prodname_code_scanning %}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ export default [
|
||||
'Permissions',
|
||||
'Policies',
|
||||
'Policy',
|
||||
'Powershell',
|
||||
'PowerShell',
|
||||
'Pre-receive hooks',
|
||||
'Privacy',
|
||||
'Profile',
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
- automation
|
||||
- title: Update Configured GitHub Actions to the Latest Versions
|
||||
description: CLI tool to check whehter all your actions are up-to-date or not
|
||||
languages: 'C#, Inno Setup, PowerSHell, Shell'
|
||||
languages: 'C#, Inno Setup, PowerShell, Shell'
|
||||
href: fabasoad/ghacu
|
||||
tags:
|
||||
- versions
|
||||
|
||||
Reference in New Issue
Block a user