mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
243
scripts/pr-deploy.js
Normal file
243
scripts/pr-deploy.js
Normal file
@@ -0,0 +1,243 @@
|
||||
var program = require('commander');
|
||||
var request = require('request');
|
||||
|
||||
var stackId = "1st550"
|
||||
|
||||
function asyncRequest(option) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
request(option, function (error, res, body) {
|
||||
if (!error && (res.statusCode == 200 || res.statusCode == 201)) {
|
||||
resolve(body);
|
||||
} else {
|
||||
reject(error + JSON.stringify(body));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-n, --name [type]', 'Name to give at the service in rancher')
|
||||
.option('-r, --remote [type]', 'Remote environment host adf.lab.com ')
|
||||
.option('-e, --env [type]', 'Name to give at the service in rancher')
|
||||
.option('-i, --image [type]', 'Docker image to load')
|
||||
.option('-s, --server [type]', 'Server RANCHER_SERVER URL')
|
||||
.option('-p, --password [type]', 'password RANCHER')
|
||||
.option('-u, --username [type]', 'username RANCHER')
|
||||
.parse(process.argv);
|
||||
|
||||
auth = 'Basic ' + new Buffer(program.username + ':' + program.password).toString('base64')
|
||||
|
||||
var project = await asyncRequest({
|
||||
url: program.server + `/v1/project?name=${program.env}`,
|
||||
method: 'GET',
|
||||
json: true,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json",
|
||||
"Authorization": auth
|
||||
},
|
||||
body: ""
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
var environmentId = project.data[0].id
|
||||
|
||||
console.log("ID environment " + environmentId);
|
||||
console.log("image to Load " + program.image);
|
||||
|
||||
var postData = {
|
||||
"scale": 1,
|
||||
"assignServiceIpAddress": false,
|
||||
"startOnCreate": true,
|
||||
"type": "service",
|
||||
"stackId": stackId,
|
||||
"launchConfig": {
|
||||
"instanceTriggeredStop": "stop",
|
||||
"kind": "container",
|
||||
"networkMode": "managed",
|
||||
"privileged": false,
|
||||
"publishAllPorts": false,
|
||||
"readOnly": false,
|
||||
"runInit": false,
|
||||
"startOnCreate": true,
|
||||
"stdinOpen": true,
|
||||
"tty": true,
|
||||
"vcpu": 1,
|
||||
"drainTimeoutMs": 0,
|
||||
"type": "launchConfig",
|
||||
"labels": {"io.rancher.container.pull_image": "always"},
|
||||
"restartPolicy": {"name": "always"},
|
||||
"secrets": [],
|
||||
"dataVolumes": [],
|
||||
"dataVolumesFrom": [],
|
||||
"dns": [],
|
||||
"dnsSearch": [],
|
||||
"capAdd": [],
|
||||
"capDrop": [],
|
||||
"devices": [],
|
||||
"logConfig": {"driver": "", "config": {}},
|
||||
"dataVolumesFromLaunchConfigs": [],
|
||||
"imageUuid": program.image,
|
||||
"ports": [],
|
||||
"blkioWeight": null,
|
||||
"cgroupParent": null,
|
||||
"count": null,
|
||||
"cpuCount": null,
|
||||
"cpuPercent": null,
|
||||
"cpuPeriod": null,
|
||||
"cpuQuota": null,
|
||||
"cpuRealtimePeriod": null,
|
||||
"cpuRealtimeRuntime": null,
|
||||
"cpuSet": null,
|
||||
"cpuSetMems": null,
|
||||
"cpuShares": null,
|
||||
"createIndex": null,
|
||||
"created": null,
|
||||
"deploymentUnitUuid": null,
|
||||
"description": null,
|
||||
"diskQuota": null,
|
||||
"domainName": null,
|
||||
"externalId": null,
|
||||
"firstRunning": null,
|
||||
"healthInterval": null,
|
||||
"healthRetries": null,
|
||||
"healthState": null,
|
||||
"healthTimeout": null,
|
||||
"hostname": null,
|
||||
"ioMaximumBandwidth": null,
|
||||
"ioMaximumIOps": null,
|
||||
"ip": null,
|
||||
"ip6": null,
|
||||
"ipcMode": null,
|
||||
"isolation": null,
|
||||
"kernelMemory": null,
|
||||
"memory": null,
|
||||
"memoryMb": null,
|
||||
"memoryReservation": null,
|
||||
"memorySwap": null,
|
||||
"memorySwappiness": null,
|
||||
"milliCpuReservation": null,
|
||||
"oomScoreAdj": null,
|
||||
"pidMode": null,
|
||||
"pidsLimit": null,
|
||||
"removed": null,
|
||||
"requestedIpAddress": null,
|
||||
"shmSize": null,
|
||||
"startCount": null,
|
||||
"stopSignal": null,
|
||||
"stopTimeout": null,
|
||||
"user": null,
|
||||
"userdata": null,
|
||||
"usernsMode": null,
|
||||
"uts": null,
|
||||
"uuid": null,
|
||||
"volumeDriver": null,
|
||||
"workingDir": null,
|
||||
"networkLaunchConfig": null
|
||||
},
|
||||
"secondaryLaunchConfigs": [],
|
||||
"name": program.name,
|
||||
"createIndex": null,
|
||||
"created": null,
|
||||
"description": null,
|
||||
"externalId": null,
|
||||
"healthState": null,
|
||||
"kind": null,
|
||||
"removed": null,
|
||||
"selectorContainer": null,
|
||||
"selectorLink": null,
|
||||
"uuid": null,
|
||||
"vip": null,
|
||||
"fqdn": null
|
||||
};
|
||||
|
||||
var createService = await asyncRequest({
|
||||
url: `${program.server}/v2-beta/projects/${environmentId}/service`,
|
||||
method: 'POST',
|
||||
json: true,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json",
|
||||
"Authorization": auth
|
||||
},
|
||||
body: postData,
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
if (!createService) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("New environment ID " + createService.id);
|
||||
|
||||
var loadBalancer = await asyncRequest({
|
||||
url: `${program.server}/v1/projects/${environmentId}/loadbalancerservices`,
|
||||
method: 'GET',
|
||||
json: true,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json",
|
||||
"Authorization": auth
|
||||
},
|
||||
body: postData,
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
if (!loadBalancer) {
|
||||
return;
|
||||
}
|
||||
|
||||
var loadBalancerId = loadBalancer.data[0].id;
|
||||
console.log("Load balancer ID " + loadBalancerId);
|
||||
|
||||
var loadBalancerGet = await asyncRequest({
|
||||
url: `${program.server}/v2-beta/projects/${environmentId}/loadbalancerservices/${loadBalancerId}`,
|
||||
method: 'GET',
|
||||
json: true,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json",
|
||||
"Authorization": auth
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
//console.log("Load balancer ID " + JSON.stringify(loadBalancerGet.lbConfig.portRules));
|
||||
|
||||
var newRule = {
|
||||
"type": "portRule",
|
||||
"hostname": program.remote,
|
||||
"path": `/${program.name}`,
|
||||
"priority": 1,
|
||||
"protocol": "http",
|
||||
"serviceId": createService.id,
|
||||
"sourcePort": 80,
|
||||
"targetPort": 80
|
||||
};
|
||||
|
||||
loadBalancerGet.lbConfig.portRules.push(newRule);
|
||||
|
||||
var loadBalancerUpdate = await asyncRequest({
|
||||
url: `${program.server}/v2-beta/projects/${environmentId}/loadbalancerservices/${loadBalancerId}`,
|
||||
method: 'PUT',
|
||||
json: true,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json",
|
||||
"Authorization": auth
|
||||
},
|
||||
body: loadBalancerGet
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
main();
|
51
scripts/pr-publish.sh
Executable file
51
scripts/pr-publish.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
|
||||
show_help() {
|
||||
echo "Usage: pr-publish.sh"
|
||||
echo ""
|
||||
echo "-n or --name pr name"
|
||||
echo "-r or --repo docker repository url"
|
||||
}
|
||||
|
||||
name_pr(){
|
||||
NAME_PR=$1
|
||||
}
|
||||
|
||||
name_docker_repo(){
|
||||
DOCKER_REPO=$1
|
||||
}
|
||||
|
||||
username_docker_repo(){
|
||||
USERNAME_DOCKER=$1
|
||||
}
|
||||
|
||||
password_docker_repo(){
|
||||
PASSWORD_DOCKER=$1
|
||||
}
|
||||
|
||||
while [[ $1 == -* ]]; do
|
||||
case "$1" in
|
||||
-h|--help|-\?) show_help; exit 0;;
|
||||
-n|--name) name_pr $2; shift 2;;
|
||||
-r|--repo) name_docker_repo $2; shift 2;;
|
||||
-u|--username) username_docker_repo $2; shift 2;;
|
||||
-p|--password) password_docker_repo $2; shift 2;;
|
||||
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd $DIR/..
|
||||
|
||||
echo "====== PUBLISH DOCKER IMAGE TAG pr $NAME_PR ====="
|
||||
|
||||
docker build -t $DOCKER_REPO/adf/demo-shell:$NAME_PR .
|
||||
|
||||
echo "====== LOGIN ====="
|
||||
docker login http://$DOCKER_REPO -p $PASSWORD_DOCKER -u $USERNAME_DOCKER
|
||||
docker push "$DOCKER_REPO/adf/demo-shell:$NAME_PR"
|
||||
|
||||
|
||||
|
||||
|
0
scripts/pr-undeploy.sh
Normal file
0
scripts/pr-undeploy.sh
Normal file
@@ -2,6 +2,26 @@
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
eval NAME=
|
||||
|
||||
show_help() {
|
||||
echo "Usage: test-dist.sh"
|
||||
echo ""
|
||||
echo "-n or --name pr name"
|
||||
}
|
||||
|
||||
name(){
|
||||
NAME="/$1"
|
||||
}
|
||||
|
||||
while [[ $1 == -* ]]; do
|
||||
case "$1" in
|
||||
-h|--help|-\?) show_help; exit 0;;
|
||||
-n|--name) name $2; shift 2;;
|
||||
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "====== Install lib ===== "
|
||||
|
||||
cd $DIR/../
|
||||
@@ -13,7 +33,7 @@ npm install alfresco-js-api@alpha
|
||||
|
||||
echo "====== Build ADF ===== "
|
||||
|
||||
npm run build-lib
|
||||
npm run build-lib || exit 1
|
||||
|
||||
echo "====== COPY new build in node_modules ===== "
|
||||
|
||||
@@ -31,8 +51,9 @@ cp -R $DIR/../lib/dist/insights/* $DIR/../node_modules/@alfresco/adf-insights
|
||||
|
||||
echo "====== Build dist demo shell ===== "
|
||||
|
||||
npm run build:dist
|
||||
npm run server-versions
|
||||
ng build --prod --app dist --base-href=$NAME/ -op demo-shell/dist/$NAME || exit 1
|
||||
|
||||
echo "====== e2e test ===== "
|
||||
|
||||
npm run e2e
|
||||
npm run e2e || exit 1
|
||||
|
61
scripts/update-project.sh
Normal file
61
scripts/update-project.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
eval GNU=false
|
||||
|
||||
set -e
|
||||
TEMP_GENERATOR_DIR=".tmp-generator";
|
||||
VERSION=$(npm view @alfresco/adf-core@beta version)
|
||||
|
||||
show_help() {
|
||||
echo "Usage: update-generator.sh"
|
||||
echo ""
|
||||
echo "-t or --token Github ouath token"
|
||||
echo "-n or --name Github name of the project"
|
||||
echo "-gnu for gnu"
|
||||
}
|
||||
|
||||
gnu_mode() {
|
||||
echo "====== GNU MODE ====="
|
||||
GNU=true
|
||||
}
|
||||
|
||||
token() {
|
||||
TOKEN=$1
|
||||
}
|
||||
|
||||
name_repo() {
|
||||
NAME_REPO=$1
|
||||
}
|
||||
|
||||
while [[ $1 == -* ]]; do
|
||||
case "$1" in
|
||||
-h|--help|-\?) show_help; exit 0;;
|
||||
-n|--name|-\?) name_repo $2; shift 2;;
|
||||
-gnu) gnu_mode; shift;;
|
||||
-t|--token) token $2; shift 2;;
|
||||
-*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
rm -rf $TEMP_GENERATOR_DIR;
|
||||
|
||||
git clone https://$TOKEN@github.com/Alfresco/$NAME_REPO.git $TEMP_GENERATOR_DIR
|
||||
cd $TEMP_GENERATOR_DIR
|
||||
git checkout development
|
||||
|
||||
BRANCH="generator-update-beta-$VERSION"
|
||||
git checkout -b $BRANCH
|
||||
|
||||
if $GNU; then
|
||||
./scripts/update-version.sh -gnu -v $VERSION
|
||||
else
|
||||
./scripts/update-version.sh -v $VERSION
|
||||
fi
|
||||
|
||||
git add .
|
||||
git commit -m "Update ADF packages version $VERSION"
|
||||
git push -u origin $BRANCH
|
||||
|
||||
curl -H "Authorization: token $TOKEN" -X POST -d '{"body":"Update ADF packages version '$VERSION'","head":"'$BRANCH'","base":"development","title":"Update ADF packages version '$VERSION'"}' https://api.github.com/repos/alfresco/$NAME_REPO/pulls
|
||||
|
||||
rm -rf $TEMP_GENERATOR_DIR;
|
Reference in New Issue
Block a user