[Doc] add a workflow sample for running a script file (#81)

This commit is contained in:
Yan Xu 2023-05-12 11:12:30 +08:00 коммит произвёл GitHub
Родитель 61f657f7aa
Коммит 12f969a5c5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 47 добавлений и 1 удалений

Просмотреть файл

@ -13,7 +13,7 @@ Login to Azure before running Azure PowerShell scripts using [Azure Login](https
Once login is done, Azure PowerShell action will use the same session to run the script.
#### Sample workflow to run inlinescript using Azure PowerShell
#### Sample workflow to run inlinescript
```yaml
on: [push]
@ -50,6 +50,52 @@ Additionally the action supports two optional parameters
- `errorActionPreference` : selecta suitable valueforthevariableforexecutingthescript.Allowed values are`stop`,`continue`,`silentlyContinue`.Defaultis`Stop`.
- `failOnStandardError` : By default this is marked as `false`. But ifthisis marked as`true`,the actionwillfailifanyerrorsarewrittentotheerrorpipeline,orifanydataiswrittentotheStandardErrorstream.
#### Sample workflow to run a script file in your repository
```yaml
# File: ./scripts/run_azps_cmdlets.ps1
on: [push]
name: AzurePowerShellSampleWithFile
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Login Azure
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true
- name: Run Azure PowerShell Script File
uses: azure/powershell@v1
with:
inlineScript: ./scripts/run_azps_cmdlets.ps1
azPSVersion: "latest"
```
You have to check out the repository before running the script file.
You can also run the script file with parameters. For example:
```yaml
- name: Run Azure PowerShell Script File
uses: azure/powershell@v1
with:
inlineScript: ./scripts/run_azps_cmdlets.ps1 myresourcegroup myresourcename
azPSVersion: "latest"
```
or
```yaml
- name: Run Azure PowerShell Script File
uses: azure/powershell@v1
with:
inlineScript: ./scripts/run_azps_cmdlets.ps1 -ResourceGroupName myresourcegroup -ResourceName myresourcename
azPSVersion: "latest"
```
### Sample workflow to run Azure powershell actions in Azure US Government cloud
```