Skip to content
This repository has been archived by the owner. It is now read-only.

GitHubCIProcess #1

Merged
merged 2 commits into from
Nov 9, 2020
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
pull_request:
branches: [ master ]
types: [opened, closed, edited, synchronize]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: npm i

47 changes: 47 additions & 0 deletions .github/workflows/publish.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: set environment variables
uses: allenevans/set-env@v1.0.0
with:
GIT_USER: ${{ secrets.WEB_GITLAB_USER }}
GIT_TOKEN: ${{ secrets.WEB_GITLAB_TOKEN }}
GIT_MAIL: ${{ secrets.USER_MAIL }}

- name: Install
run: npm i

- name: Get changed files
run: |
git diff --name-only HEAD^ HEAD

- name: Publish
run: npm run publish
env:
GIT_USER: ${{ secrets.WEB_GITLAB_USER }}
GIT_TOKEN: ${{ secrets.WEB_GITLAB_TOKEN }}
GIT_MAIL: ${{ secrets.USER_MAIL }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.npmrc
dist/
.vscode/
coverage/
index.js
index.d.ts
gulpfile.js
node_modules/
88 changes: 88 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
var fs = require('fs');
var gulp = require('gulp');
var glob = require('glob');
var shelljs = require('shelljs');
var path = require('path');
var branch = 'master';
var user = process.env.GIT_USER;
var token = process.env.GIT_TOKEN;
var user_mail = process.env.GIT_MAIL;
var is_temp = process.env.IS_TEMP;
var changedFileNames;
var changes;
/**
* Source shipping to gitlab
*/
gulp.task('ship-to-gitlab', function (done) {
changedFileNames = changedFileNameList();
console.log('--changedFileNames----' + changedFileNames);
var gitPath = 'https://' + user + ':' + token + `@gitlab.syncfusion.com/content/php-docs`;
console.log('Clone has been started...!');
var clone = shelljs.exec('git clone ' + gitPath + ' -b ' + branch + ' ' + `../../../gitlabRepo/php-docs`, {
silent: false
});
if (clone.code !== 0) {
console.log(clone.stderr);
done();
return;
} else {
console.log('Clone has been completed...!');
// update src from github to gitlab - replace files from cloned repo

for (var changedFileName of changedFileNames.split(',')) {

if (changedFileName !== null && changedFileName !== '') {

if (fs.existsSync('../php-docs/' + changedFileName)) {
// It will update the modified files
if (fs.existsSync('../../../gitlabRepo/php-docs/' + changedFileName)) {
shelljs.cp('-rf', `../php-docs/` + changedFileName, `../../../gitlabRepo/php-docs/` + changedFileName);
}
else {
// It will update the newly added files
if (fs.existsSync('../../../gitlabRepo/php-docs/')) {
shelljs.cp('-rf', `../php-docs/` + changedFileName, `../../../gitlabRepo/php-docs/` + changedFileName);
}
}

}
else {
// It will remove the deleted files
if (fs.existsSync('../../../gitlabRepo/php-docs/' + changedFileName)) {
shelljs.rm('-rf', `../../../gitlabRepo/php-docs/` + changedFileName);

}
}

}

}

shelljs.cd(`../../../gitlabRepo/php-docs`);
shelljs.exec('git add .');
shelljs.exec('git pull');
shelljs.exec('git commit -m \"source updation from github repo \" --no-verify');
shelljs.exec('git push');
shelljs.cd('../../');
}
})

// Controls List
function changedFileNameList() {
shelljs.exec(`git config --global user.email "${user_mail}"`);
shelljs.exec(`git config --global user.name "${user}"`);
changes = shelljs.exec(`git diff --name-status HEAD^ HEAD`);
var controls = '';
var changesList = changes.stdout.split('\n');
if (changesList !== null && changesList !== '') {
for (var comp of changesList) {
controls += comp.replace(/A\s+/g, "").replace(/M\s+/g, "").replace(/D\s+/g, "").replace(/R100\s+/g, "").split(/\s+/g) + ',';
}
return controls;
}
}





46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@Syncfusion/php-docs",
"version": "1.0.0",
"description": "Syncfusion TypeScript common documentation",
"author": "Syncfusion Inc.",
"license": "UNLICENSED",
"dependencies": {
"core-js": "^2.5.7",
"cheerio": "^1.0.0-rc.2",
"gulp": "^3.9.1",
"gulp-csslint": "^1.0.1",
"gulp-csslint-report": "^2.0.0",
"gulp-gzip": "^1.4.2",
"lodash": "^4.17.11",
"markdownlint": "^0.11.0",
"markdown-link-extractor": "^1.2.0",
"markdown-spellcheck": "^1.3.1",
"prismjs": "^1.15.0",
"require-dir": "^1.0.0",
"shelljs": "^0.8.2",
"styled-components": "^3.4.9",
"typeface-merriweather": "0.0.43",
"typeface-montserrat": "0.0.43",
"typo-js": "^1.0.3",
"typescript": "^2.6.2",
"typography": "^0.16.17",
"typography-theme-wordpress-2016": "^0.15.10",
"webpack": "4.28.4",
"terser": "3.14.1"
},
"devDependencies": {
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.11.1",
"gh-pages": "^1.2.0",
"json-loader": "^0.5.7",
"prettier": "^1.14.2"
},
"config": {
"ghooks": {
"pre-commit": "gulp test"
}
},
"scripts": {
"publish": "gulp ship-to-gitlab"
}
}