зеркало из https://github.com/Azure/cli.git
Set user agent for Azure/CLI action (#122)
* set user agent for azure cli action * remove version * encode user repo with hash * compile * reset AZURE_HTTP_USER_AGENT
This commit is contained in:
Родитель
7a3e41a6ff
Коммит
a4cc5951d6
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -3,6 +3,7 @@ import * as exec from '@actions/exec';
|
|||
import * as io from '@actions/io';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as crypto from 'crypto';
|
||||
const util = require('util');
|
||||
const cpExec = util.promisify(require('child_process').exec);
|
||||
|
||||
|
@ -10,8 +11,14 @@ import { createScriptFile, TEMP_DIRECTORY, NullOutstreamStringWritable, deleteFi
|
|||
|
||||
const START_SCRIPT_EXECUTION_MARKER: string = "Starting script execution via docker image mcr.microsoft.com/azure-cli:";
|
||||
const AZ_CLI_VERSION_DEFAULT_VALUE = 'agentazcliversion'
|
||||
const prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
|
||||
|
||||
export async function main() {
|
||||
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
|
||||
let actionName = 'AzureCLIAction';
|
||||
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}_${usrAgentRepo}`;
|
||||
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
||||
|
||||
var scriptFileName: string = '';
|
||||
const CONTAINER_NAME = `MICROSOFT_AZURE_CLI_${getCurrentTime()}_CONTAINER`;
|
||||
try {
|
||||
|
@ -83,6 +90,8 @@ export async function main() {
|
|||
await deleteFile(scriptFilePath);
|
||||
console.log("cleaning up container...");
|
||||
await executeDockerCommand(["rm", "--force", CONTAINER_NAME], true);
|
||||
// Reset AZURE_HTTP_USER_AGENT
|
||||
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче