Skip to content
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

Update README.md to support macOS and self-hosted runners #92

Merged
merged 3 commits into from
Nov 20, 2023
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
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# GitHub action for Azure PowerShell

This repository contains GitHub action for Azure PowerShell to automate your GitHub workflows using Azure PowerShell scripts.

Get started today with a [free Azure account](https://azure.com/free/open-source)!

The definition of this GitHub Action is in [action.yml](https://github.com/azure/powershell/blob/master/action.yml).

## End-to-End Sample Workflow
> [!NOTE]
> Azure PowerShell action now supports macOS and self-hosted Runners!

### Dependencies on other GitHub Actions
## Dependencies on other GitHub Actions

Login to Azure before running Azure PowerShell scripts using [Azure Login](https://github.com/Azure/login). Refer [Azure Login](https://github.com/Azure/login#configure-azure-credentials) action on how to configure Azure credentials.

Once login is done, Azure PowerShell action will use the same session to run the script.
Both [Azure Login](https://github.com/Azure/login) and [Azure PowerShell](https://github.com/azure/powershell) action uses `Az` module.

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

## Sample Workflow

### Sample workflow to run inlineScript

#### Sample workflow to run inlinescript
```yaml
on: [push]

Expand All @@ -31,26 +38,25 @@ jobs:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true

- name: Run Azure PowerShell script
- name: Run Azure PowerShell inline script
uses: azure/powershell@v1
with:
inlineScript: |
Get-AzVM -ResourceGroupName "ResourceGroup11"
azPSVersion: "latest"
```
Azure PowerShell Script to be executed can be given under inlineScript as shown in the sample workflow.

Both [Azure Login](https://github.com/Azure/login) and [Azure PowerShell](https://github.com/azure/powershell) action uses Az module.
Azure PowerShell Script to be executed can be given under inlineScript as shown in the sample workflow.

Currently, Azure PowerShell action only supports ubuntu and windows runners. MacOS is not supported. Self hosted runners are not supported.
Azure PowerShell action is now supported for the Azure public cloud as well as Azure government clouds (`AzureUSGovernment` or `AzureChinaCloud`) and Azure Stack (`AzureStack`) Hub. Before running Azure PowerShell scripts, login to the respective Azure Cloud using [Azure Login action](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter.

Azure PowerShell action is now supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud') and Azure Stack ('AzureStack') Hub. Before running Azure PowerShell scripts, login to the respective Azure Cloud using [Azure Login](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter.
Additionally the action supports two optional parameters:

Additionally the action supports two optional parameters
- `errorActionPreference` : select a suitable  value for the variable for executing the script. Allowed values are `stop`, `continue`, `silentlyContinue`. Default is `Stop`.
- `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.

#### Sample workflow to run a script file in your repository
### Sample workflow to run a script file in your repository

```yaml
# File: ./scripts/run_azps_cmdlets.ps1
on: [push]
Expand Down Expand Up @@ -78,16 +84,20 @@ jobs:
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
Expand All @@ -98,13 +108,9 @@ or

### Sample workflow to run Azure powershell actions in Azure US Government cloud

```
.......
.......
.......

```yaml
- name: Login to Azure US Gov Cloud with Az Powershell
uses: azure/login@releases/azcloud-v1
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_US_GOV_CREDENTIALS }}
environment: 'AzureUSGovernment'
Expand All @@ -117,20 +123,22 @@ or
azPSVersion: "latest"
```

#### Available versions of Az Module on runner
## Available versions of Az Module on runner

To use the latest Az module version, specify `latest`. You can find the latest Az module versions on different runner images from this [table](https://github.com/actions/runner-images#available-images).

To use the latest Az module version, specify 'latest'. You can find the latest Az module versions on different runner images from this [table](https://github.com/actions/runner-images#available-images).
Or you can find all supported `Az` version on [PowerShell Gallery](https://www.powershellgallery.com/packages/Az).

# Getting Help for Azure PowerShell Issues
## Getting Help for Azure PowerShell Issues

If you encounter an issue related to the Azure PowerShell commands executed in your script, you can
If you encounter an issue related to the Azure PowerShell commands executed in your script, you can
file an issue directly on the [Azure PowerShell repository](https://github.com/Azure/azure-powershell/issues/new/choose).

# Contributing
## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
Expand Down
Loading