Skip to content

Commit 12f969a

Browse files
authored
[Doc] add a workflow sample for running a script file (#81)
1 parent 61f657f commit 12f969a

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Login to Azure before running Azure PowerShell scripts using [Azure Login](https
1313

1414
Once login is done, Azure PowerShell action will use the same session to run the script.
1515

16-
#### Sample workflow to run inlinescript using Azure PowerShell
16+
#### Sample workflow to run inlinescript
1717
```yaml
1818
on: [push]
1919

@@ -50,6 +50,52 @@ Additionally the action supports two optional parameters
5050
- `errorActionPreference` : select a suitable  value for the variable for executing the script. Allowed values are `stop`, `continue`, `silentlyContinue`. Default is `Stop`.
5151
- `failOnStandardError` : By default this is marked as `false`. But if this is marked as `true`, the action will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream.
5252

53+
#### Sample workflow to run a script file in your repository
54+
```yaml
55+
# File: ./scripts/run_azps_cmdlets.ps1
56+
on: [push]
57+
58+
name: AzurePowerShellSampleWithFile
59+
60+
jobs:
61+
62+
build:
63+
runs-on: ubuntu-latest
64+
steps:
65+
66+
- name: Check Out
67+
uses: actions/checkout@v3
68+
69+
- name: Login Azure
70+
uses: azure/login@v1
71+
with:
72+
creds: ${{secrets.AZURE_CREDENTIALS}}
73+
enable-AzPSSession: true
74+
75+
- name: Run Azure PowerShell Script File
76+
uses: azure/powershell@v1
77+
with:
78+
inlineScript: ./scripts/run_azps_cmdlets.ps1
79+
azPSVersion: "latest"
80+
```
81+
You have to check out the repository before running the script file.
82+
You can also run the script file with parameters. For example:
83+
```yaml
84+
- name: Run Azure PowerShell Script File
85+
uses: azure/powershell@v1
86+
with:
87+
inlineScript: ./scripts/run_azps_cmdlets.ps1 myresourcegroup myresourcename
88+
azPSVersion: "latest"
89+
```
90+
or
91+
```yaml
92+
- name: Run Azure PowerShell Script File
93+
uses: azure/powershell@v1
94+
with:
95+
inlineScript: ./scripts/run_azps_cmdlets.ps1 -ResourceGroupName myresourcegroup -ResourceName myresourcename
96+
azPSVersion: "latest"
97+
```
98+
5399
### Sample workflow to run Azure powershell actions in Azure US Government cloud
54100

55101
```

0 commit comments

Comments
 (0)