Skip to content

Commit

Permalink
Revert "Releasing v1.1.2" (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanika1894 authored May 10, 2021
1 parent 02723d1 commit 69077f2
Show file tree
Hide file tree
Showing 4 changed files with 412 additions and 425 deletions.
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t contoso.azurecr.io/nodejssampleapp:${{ github.sha }}
docker build .t contoso.azurecr.io/nodejssampleapp:${{ github.sha }}
docker push contoso.azurecr.io/nodejssampleapp:${{ github.sha }}
- name: 'Deploy to Azure Container Instances'
Expand Down Expand Up @@ -134,18 +134,6 @@ jobs:
location: 'east us'
```
# Local Development and Testing
If you wish to develop and test changes against a local fork or development repo, you can do so by including the `node_modules` in tagged release branch. Note that the `aci-deploy` repository does not include these modules in the master branch, so you cannot point your action to `aci-deploy/master` to pick up recent commits.

Testing can be performed against your local repo by performing the following:

* Fork this repo.
* Create a separate branch on your local copy. This will be used to execute the action from your workflow.
* Perform an `npm install` and `npm run build`
* Ensure that you check in the `node_modules` directory to your branch.
* Update your workflow to refer to your tagged release from forked copy.

# Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
246 changes: 123 additions & 123 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const crypto = __importStar(require("crypto"));
const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory");
const arm_containerinstance_1 = require("@azure/arm-containerinstance");
const ms_rest_js_1 = require("@azure/ms-rest-js");
const taskparameters_1 = require("./taskparameters");
var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
function main() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
// Set user agent variable
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
let actionName = 'DeployAzureContainerInstance';
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`;
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
let endpoint = yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer();
var taskParams = taskparameters_1.TaskParameters.getTaskParams(endpoint);
let bearerToken = yield endpoint.getToken();
let creds = new ms_rest_js_1.TokenCredentials(bearerToken);
core.debug("Predeployment Steps Started");
const client = new arm_containerinstance_1.ContainerInstanceManagementClient(creds, taskParams.subscriptionId);
core.debug("Deployment Step Started");
let containerGroupInstance = {
"location": taskParams.location,
"containers": [
{
"name": taskParams.containerName,
"command": taskParams.commandLine,
"environmentVariables": taskParams.environmentVariables,
"image": taskParams.image,
"ports": taskParams.ports,
"resources": getResources(taskParams),
"volumeMounts": taskParams.volumeMounts
}
],
"imageRegistryCredentials": taskParams.registryUsername ? [{ "server": taskParams.registryLoginServer, "username": taskParams.registryUsername, "password": taskParams.registryPassword }] : [],
"ipAddress": {
"ports": getPorts(taskParams),
"type": taskParams.ipAddress,
"dnsNameLabel": taskParams.dnsNameLabel
},
"diagnostics": taskParams.diagnostics,
"volumes": taskParams.volumes,
"osType": taskParams.osType,
"restartPolicy": taskParams.restartPolicy,
"type": "Microsoft.ContainerInstance/containerGroups",
"name": taskParams.containerName
};
let containerDeploymentResult = yield client.containerGroups.createOrUpdate(taskParams.resourceGroup, taskParams.containerName, containerGroupInstance);
if (containerDeploymentResult.provisioningState == "Succeeded") {
console.log("Deployment Succeeded.");
let appUrlWithoutPort = (_a = containerDeploymentResult.ipAddress) === null || _a === void 0 ? void 0 : _a.fqdn;
let port = taskParams.ports[0].port;
let appUrl = "http://" + appUrlWithoutPort + ":" + port.toString() + "/";
core.setOutput("app-url", appUrl);
console.log("Your App has been deployed at: " + appUrl);
}
else {
core.debug("Deployment Result: " + containerDeploymentResult);
throw Error("Container Deployment Failed" + containerDeploymentResult);
}
}
catch (error) {
core.debug("Deployment Failed with Error: " + error);
core.setFailed(error);
}
finally {
// Reset AZURE_HTTP_USER_AGENT
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
}
});
}
function getResources(taskParams) {
if (taskParams.gpuCount) {
let resRequirements = {
"requests": {
"cpu": taskParams.cpu,
"memoryInGB": taskParams.memory,
"gpu": {
"count": taskParams.gpuCount,
"sku": taskParams.gpuSku
}
}
};
return resRequirements;
}
else {
let resRequirements = {
"requests": {
"cpu": taskParams.cpu,
"memoryInGB": taskParams.memory
}
};
return resRequirements;
}
}
function getPorts(taskParams) {
let ports = taskParams.ports;
ports.forEach((port) => {
port.protocol = taskParams.protocol;
});
return ports;
}
main();
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const crypto = __importStar(require("crypto"));
const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory");
const arm_containerinstance_1 = require("@azure/arm-containerinstance");
const ms_rest_js_1 = require("@azure/ms-rest-js");
const taskparameters_1 = require("./taskparameters");
var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : "";
function main() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
// Set user agent variable
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
let actionName = 'DeployAzureContainerInstance';
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`;
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
let endpoint = yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer();
var taskParams = taskparameters_1.TaskParameters.getTaskParams(endpoint);
let bearerToken = yield endpoint.getToken();
let creds = new ms_rest_js_1.TokenCredentials(bearerToken);
core.debug("Predeployment Steps Started");
const client = new arm_containerinstance_1.ContainerInstanceManagementClient(creds, taskParams.subscriptionId);
core.debug("Deployment Step Started");
let containerGroupInstance = {
"location": taskParams.location,
"containers": [
{
"name": taskParams.containerName,
"command": taskParams.commandLine,
"environmentVariables": taskParams.environmentVariables,
"image": taskParams.image,
"ports": taskParams.ports,
"resources": getResources(taskParams),
"volumeMounts": taskParams.volumeMounts
}
],
"imageRegistryCredentials": taskParams.registryUsername ? [{ "server": taskParams.registryLoginServer, "username": taskParams.registryUsername, "password": taskParams.registryPassword }] : [],
"ipAddress": {
"ports": getPorts(taskParams),
"type": taskParams.ipAddress,
"dnsNameLabel": taskParams.dnsNameLabel
},
"diagnostics": taskParams.diagnostics,
"volumes": taskParams.volumes,
"osType": taskParams.osType,
"restartPolicy": taskParams.restartPolicy,
"type": "Microsoft.ContainerInstance/containerGroups",
"name": taskParams.containerName
};
let containerDeploymentResult = yield client.containerGroups.createOrUpdate(taskParams.resourceGroup, taskParams.containerName, containerGroupInstance);
if (containerDeploymentResult.provisioningState == "Succeeded") {
console.log("Deployment Succeeded.");
let appUrlWithoutPort = (_a = containerDeploymentResult.ipAddress) === null || _a === void 0 ? void 0 : _a.fqdn;
let port = taskParams.ports[0].port;
let appUrl = "http://" + appUrlWithoutPort + ":" + port.toString() + "/";
core.setOutput("app-url", appUrl);
console.log("Your App has been deployed at: " + appUrl);
}
else {
core.debug("Deployment Result: " + containerDeploymentResult);
throw Error("Container Deployment Failed" + containerDeploymentResult);
}
}
catch (error) {
core.debug("Deployment Failed with Error: " + error);
core.setFailed(error);
}
finally {
// Reset AZURE_HTTP_USER_AGENT
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
}
});
}
function getResources(taskParams) {
if (taskParams.gpuCount) {
let resRequirements = {
"requests": {
"cpu": taskParams.cpu,
"memoryInGB": taskParams.memory,
"gpu": {
"count": taskParams.gpuCount,
"sku": taskParams.gpuSku
}
}
};
return resRequirements;
}
else {
let resRequirements = {
"requests": {
"cpu": taskParams.cpu,
"memoryInGB": taskParams.memory
}
};
return resRequirements;
}
}
function getPorts(taskParams) {
let ports = taskParams.ports;
ports.forEach((port) => {
port.protocol = taskParams.protocol;
});
return ports;
}
main();
Loading

0 comments on commit 69077f2

Please sign in to comment.