Update azure/CLI@v1 to azure/cli@v2 and azure/powershell@v1 to azure/powershell@v2 (#438)

* patch

* fix indentation
This commit is contained in:
Jiashuo Li
2024-04-26 08:58:16 +08:00
committed by GitHub
parent 19d77c4f9b
commit cf8f85dbab

View File

@@ -183,9 +183,9 @@ name: Run Azure Login with OIDC
on: [push] on: [push]
permissions: permissions:
id-token: write id-token: write
contents: read contents: read
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -195,9 +195,9 @@ jobs:
client-id: ${{ secrets.AZURE_CLIENT_ID }} client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
@@ -213,9 +213,9 @@ name: Run Azure Login with OIDC
on: [push] on: [push]
permissions: permissions:
id-token: write id-token: write
contents: read contents: read
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -226,16 +226,16 @@ jobs:
tenant-id: ${{ secrets.AZURE_TENANT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true enable-AzPSSession: true
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
- name: Azure PowerShell script - name: Azure PowerShell script
uses: azure/powershell@v1 uses: azure/powershell@v2
with: with:
azPSVersion: "latest" azPSVersion: "latest"
inlineScript: | inlineScript: |
@@ -281,18 +281,17 @@ jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: azure/login@v2 - uses: azure/login@v2
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
``` ```
- **The workflow sample to run both Azure CLI and Azure PowerShell** - **The workflow sample to run both Azure CLI and Azure PowerShell**
@@ -309,21 +308,21 @@ jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: azure/login@v2 - uses: azure/login@v2
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true enable-AzPSSession: true
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
- name: Azure PowerShell script - name: Azure PowerShell script
uses: azure/powershell@v1 uses: azure/powershell@v2
with: with:
azPSVersion: "latest" azPSVersion: "latest"
inlineScript: | inlineScript: |
@@ -372,29 +371,29 @@ Now you can try the workflow to login with system-assigned managed identity.
name: Run Azure Login with System-assigned Managed Identity name: Run Azure Login with System-assigned Managed Identity
on: [push] on: [push]
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- name: Azure login - name: Azure login
uses: azure/login@v2 uses: azure/login@v2
with: with:
auth-type: IDENTITY auth-type: IDENTITY
tenant-id: ${{ secrets.AZURE_TENANT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true enable-AzPSSession: true
# Azure CLI Action only supports linux self-hosted runners for now. # Azure CLI Action only supports linux self-hosted runners for now.
# If you want to execute the Azure CLI script on a windows self-hosted runner, you can execute it directly in `run`. # If you want to execute the Azure CLI script on a windows self-hosted runner, you can execute it directly in `run`.
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
- name: Azure PowerShell script - name: Azure PowerShell script
uses: azure/powershell@v1 uses: azure/powershell@v2
with: with:
azPSVersion: "latest" azPSVersion: "latest"
inlineScript: | inlineScript: |
@@ -438,7 +437,7 @@ Now you can try the workflow to login with user-assigned managed identity.
name: Run Azure Login with User-assigned Managed Identity name: Run Azure Login with User-assigned Managed Identity
on: [push] on: [push]
jobs: jobs:
build-and-deploy: build-and-deploy:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
@@ -446,22 +445,22 @@ jobs:
uses: azure/login@v2 uses: azure/login@v2
with: with:
auth-type: IDENTITY auth-type: IDENTITY
client-id: ${{ secrets.AZURE_CLIENT_ID }} client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true enable-AzPSSession: true
# Azure CLI Action only supports linux self-hosted runners for now. # Azure CLI Action only supports linux self-hosted runners for now.
# If you want to execute the Azure CLI script on a windows self-hosted runner, you can execute it directly in `run`. # If you want to execute the Azure CLI script on a windows self-hosted runner, you can execute it directly in `run`.
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
- name: Azure PowerShell script - name: Azure PowerShell script
uses: azure/powershell@v1 uses: azure/powershell@v2
with: with:
azPSVersion: "latest" azPSVersion: "latest"
inlineScript: | inlineScript: |
@@ -482,13 +481,12 @@ jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: azure/login@v2 - uses: azure/login@v2
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} creds: ${{ secrets.AZURE_CREDENTIALS }}
environment: 'AzureUSGovernment' environment: 'AzureUSGovernment'
enable-AzPSSession: true enable-AzPSSession: true
``` ```
### Login to Azure Stack Hub ### Login to Azure Stack Hub
@@ -505,13 +503,12 @@ jobs:
build-and-deploy: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: azure/login@v2 - uses: azure/login@v2
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} creds: ${{ secrets.AZURE_CREDENTIALS }}
environment: 'AzureStack' environment: 'AzureStack'
enable-AzPSSession: true enable-AzPSSession: true
``` ```
Refer to the [Azure Stack Hub Login Action Tutorial](https://learn.microsoft.com/azure-stack/user/ci-cd-github-action-login-cli) for more detailed instructions. Refer to the [Azure Stack Hub Login Action Tutorial](https://learn.microsoft.com/azure-stack/user/ci-cd-github-action-login-cli) for more detailed instructions.
@@ -542,14 +539,14 @@ jobs:
enable-AzPSSession: true enable-AzPSSession: true
- name: Azure CLI script - name: Azure CLI script
uses: azure/CLI@v1 uses: azure/cli@v2
with: with:
azcliversion: latest azcliversion: latest
inlineScript: | inlineScript: |
az account show az account show
- name: Run Azure PowerShell - name: Run Azure PowerShell
uses: azure/powershell@v1 uses: azure/powershell@v2
with: with:
azPSVersion: "latest" azPSVersion: "latest"
inlineScript: | inlineScript: |