Skip to content
Open
Show file tree
Hide file tree
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
35 changes: 19 additions & 16 deletions .github/workflows/azure-login-live-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ permissions:
id-token: write
contents: read

# One resource group is shared by every job in this run, so serialize runs to
# avoid one run tearing down another's group.
# Each run provisions its own uniquely-named resource group (suffixed with the
# run id), so concurrent runs on different branches/PRs never collide or tear
# down each other's group. The concurrency group is branch-scoped only to avoid
# piling up runs on rapid pushes to the same ref - it does NOT serialize across
# the whole repo, so an unapproved run on one PR can never block another.
concurrency:
group: azure-login-live-tests
group: azure-login-live-tests-${{ github.ref }}
cancel-in-progress: false

env:
# Created once in setup; the positive and embedded "can access" assertions
# target this group.
RG_POSITIVE: GitHubAction_CI_Group
# target this group. Suffixed with the run id so every run is isolated.
RG_POSITIVE: GitHubAction_CI_Group_${{ github.run_id }}
LOCATION: eastus
# Intentionally NEVER created: the negative permission/not-found assertions
# target this name so they fail as expected.
Expand All @@ -38,7 +41,7 @@ jobs:
with:
creds: ${{ secrets.PROVISION_CREDS }}
- name: Create resource group
run: az group create --name "$RG_POSITIVE" --location "$LOCATION" --output none
run: az group create --name "${{ env.RG_POSITIVE }}" --location "${{ env.LOCATION }}" --output none

# ================================================================ POSITIVE
Positive_BasicTest:
Expand Down Expand Up @@ -77,7 +80,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Run Azure PowerShell
uses: azure/powershell@v3
Expand Down Expand Up @@ -121,7 +124,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Run Azure PowerShell
uses: azure/powershell@v3
Expand Down Expand Up @@ -165,7 +168,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Login with creds, wrong boolean value
uses: ./
Expand All @@ -176,7 +179,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Login with creds, allow no subscription
uses: ./
Expand All @@ -188,7 +191,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Run Azure PowerShell
uses: azure/powershell@v3
Expand Down Expand Up @@ -521,7 +524,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Run Azure PowerShell
id: ps_8
Expand All @@ -531,7 +534,7 @@ jobs:
azPSVersion: "latest"
inlineScript: |
(Get-AzContext).Environment.Name -eq 'AzureCloud'
(Get-AzResourceGroup -Name GitHubAction_CI_Group).ResourceGroupName -eq 'GitHubAction_CI_Group'
(Get-AzResourceGroup -Name $env:RG_POSITIVE).ResourceGroupName -eq $env:RG_POSITIVE

- name: Check Last step failed
if: steps.ps_8.outcome == 'success'
Expand All @@ -549,7 +552,7 @@ jobs:
- name: Run Azure Cli
run: |
az account show --output none
az group show --name GitHubAction_CI_Group --output none
az group show --name "${{ env.RG_POSITIVE }}" --output none

- name: Run Azure PowerShell
id: ps_9
Expand All @@ -559,7 +562,7 @@ jobs:
azPSVersion: "latest"
inlineScript: |
(Get-AzContext).Environment.Name -eq 'AzureCloud'
(Get-AzResourceGroup -Name GitHubAction_CI_Group).ResourceGroupName -eq 'GitHubAction_CI_Group'
(Get-AzResourceGroup -Name $env:RG_POSITIVE).ResourceGroupName -eq $env:RG_POSITIVE

- name: Check Last step failed
if: steps.ps_9.outcome == 'success'
Expand Down Expand Up @@ -687,4 +690,4 @@ jobs:
with:
creds: ${{ secrets.PROVISION_CREDS }}
- name: Delete resource group
run: az group delete --name "$RG_POSITIVE" --yes --output none || true
run: az group delete --name "${{ env.RG_POSITIVE }}" --yes --output none || true
5 changes: 3 additions & 2 deletions src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { AzPSConstants, AzPSUtils } from '../PowerShell/AzPSUtils';
export function setUserAgent(): void {
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
let actionName = 'AzureLogin';
process.env.AZURE_HTTP_USER_AGENT = (!!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT} ` : '') + `GITHUBACTIONS/${actionName}@v3_${usrAgentRepo}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`;
process.env.AZUREPS_HOST_ENVIRONMENT = (!!process.env.AZUREPS_HOST_ENVIRONMENT ? `${process.env.AZUREPS_HOST_ENVIRONMENT} ` : '') + `GITHUBACTIONS/${actionName}@v3_${usrAgentRepo}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`;
let actionRef = process.env.GITHUB_ACTION_REF || 'unknown';
process.env.AZURE_HTTP_USER_AGENT = (!!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT} ` : '') + `GITHUBACTIONS/${actionName}@${actionRef}_${usrAgentRepo}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`;
process.env.AZUREPS_HOST_ENVIRONMENT = (!!process.env.AZUREPS_HOST_ENVIRONMENT ? `${process.env.AZUREPS_HOST_ENVIRONMENT} ` : '') + `GITHUBACTIONS/${actionName}@${actionRef}_${usrAgentRepo}_${process.env.RUNNER_ENVIRONMENT}_${process.env.GITHUB_RUN_ID}`;
}

export async function cleanupAzCLIAccounts(): Promise<void> {
Expand Down
Loading