Skip to content

Commit

Permalink
feat: add cloud endpoint support
Browse files Browse the repository at this point in the history
  • Loading branch information
ljtill committed Nov 18, 2024
1 parent bd76686 commit f50dadb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
9 changes: 6 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ description: "GitHub Action for deploying to Azure"
author: "Microsoft"

branding:
icon: 'upload-cloud'
color: 'blue'
icon: "upload-cloud"
color: "blue"

inputs:
type:
Expand Down Expand Up @@ -54,7 +54,6 @@ inputs:
description: "Specifies the parameters to use."
required: false


what-if-exclude-change-types:
description: "Specifies the change types to exclude from the 'What If' operation."
required: false
Expand Down Expand Up @@ -93,6 +92,10 @@ inputs:
description: "Specifies output names to mask values for."
required: false

cloud:
description: "Specifies the cloud to use. Choose from 'AzureCloud', 'AzureChinaCloud', 'AzureGermanCloud', 'AzureUSGovernment'."
required: false

runs:
using: node20
main: dist/index.js
23 changes: 23 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59791,8 +59791,29 @@ const arm_resources_1 = __nccwpck_require__(6271);
const arm_resourcesdeploymentstacks_1 = __nccwpck_require__(9821);
const identity_1 = __nccwpck_require__(3983);
const core_1 = __nccwpck_require__(7484);
const input_1 = __nccwpck_require__(5397);
const userAgentPrefix = "gh-azure-bicep-deploy";
const dummySubscriptionId = "00000000-0000-0000-0000-000000000000";
function getEndpoint() {
const cloud = (0, input_1.getOptionalEnumInput)("cloud", [
"AzureChinaCloud",
"AzureUSGovernment",
"AzureGermanCloud",
]);
let endpoint;
switch (cloud) {
case "AzureChinaCloud":
endpoint = "https://management.chinacloudapi.cn";
break;
case "AzureGermanCloud":
endpoint = "https://management.microsoftazure.de";
break;
case "AzureUSGovernment":
endpoint = "https://management.usgovcloudapi.net";
break;
}
return endpoint;
}
function createDeploymentClient(subscriptionId, tenantId) {
const credentials = new identity_1.DefaultAzureCredential({ tenantId });
return new arm_resources_1.ResourceManagementClient(credentials,
Expand All @@ -59804,6 +59825,7 @@ function createDeploymentClient(subscriptionId, tenantId) {
additionalPolicies: [debugLoggingPolicy],
// Use a recent API version to take advantage of error improvements
apiVersion: "2024-03-01",
endpoint: getEndpoint(),
});
}
function createStacksClient(subscriptionId, tenantId) {
Expand All @@ -59815,6 +59837,7 @@ function createStacksClient(subscriptionId, tenantId) {
userAgentPrefix: userAgentPrefix,
},
additionalPolicies: [debugLoggingPolicy],
endpoint: getEndpoint(),
});
}
// Log request + response bodies to GitHub Actions debug output if enabled
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/helpers/azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,34 @@ import { DefaultAzureCredential } from "@azure/identity";
import { AdditionalPolicyConfig } from "@azure/core-client";
import { debug, isDebug } from "@actions/core";

import { getOptionalEnumInput } from "./input";

const userAgentPrefix = "gh-azure-bicep-deploy";
const dummySubscriptionId = "00000000-0000-0000-0000-000000000000";

function getEndpoint(): string | undefined {
const cloud = getOptionalEnumInput("cloud", [
"AzureChinaCloud",
"AzureUSGovernment",
"AzureGermanCloud",
]);
let endpoint: string | undefined;

switch (cloud) {
case "AzureChinaCloud":
endpoint = "https://management.chinacloudapi.cn";
break;
case "AzureGermanCloud":
endpoint = "https://management.microsoftazure.de";
break;
case "AzureUSGovernment":
endpoint = "https://management.usgovcloudapi.net";
break;
}

return endpoint;
}

export function createDeploymentClient(
subscriptionId?: string,
tenantId?: string,
Expand All @@ -26,6 +51,7 @@ export function createDeploymentClient(
additionalPolicies: [debugLoggingPolicy],
// Use a recent API version to take advantage of error improvements
apiVersion: "2024-03-01",
endpoint: getEndpoint(),
},
);
}
Expand All @@ -45,6 +71,7 @@ export function createStacksClient(
userAgentPrefix: userAgentPrefix,
},
additionalPolicies: [debugLoggingPolicy],
endpoint: getEndpoint(),
},
);
}
Expand Down

0 comments on commit f50dadb

Please sign in to comment.