8
0
Pārlūkot izejas kodu

Moved "cleaning docs repo" script to other file.

Kamil Piechaczek 7 gadi atpakaļ
vecāks
revīzija
7e5fedb324

+ 0 - 3
.travis.yml

@@ -27,9 +27,6 @@ script:
   - 'if [ $TRAVIS_TEST_RESULT -eq 0 ]; then
   	  travis_wait npm run docs:build-and-publish-nightly;
     fi'
-  - 'if [ $TRAVIS_TEST_RESULT -eq 0 ]; then
-  	  travis_wait node ./scripts/docs/clean-up-repository.js;
-    fi'
 notifications:
   slack:
     rooms:

+ 21 - 0
scripts/docs/build-and-publish-nightly.js

@@ -76,6 +76,27 @@ if ( exec( 'git diff --name-only docs/' ).trim().length ) {
 	console.log( 'Nothing to commit. Documentation is up to date.' );
 }
 
+// Every 10th day of the month, we would like to clean the history of the documentation repository.
+if ( new Date().getDate() === 10 ) {
+	// Copy a commit which will be a new root in the repository.
+	const commit = exec( 'git log --oneline --reverse -5 --format="%h" | head -n 1' ).trim();
+
+	// Checkout to the status of the git repo at commit. Create a temporary branch.
+	exec( `git checkout --orphan temp ${ commit }` );
+
+	// Create a new commit that is to be the new root commit.
+	exec( 'git commit -m "Documentation build."' );
+
+	// Rebase the part of history from <commit> to master on the temporary branch.
+	exec( `git rebase --onto temp ${ commit } master` );
+
+	// Remove the temporary branch.
+	exec( 'git branch -D temp' );
+
+	// Pray.
+	exec( 'git push -f' );
+}
+
 // Change work directory to the previous value.
 process.chdir( ROOT_PATH );
 

+ 0 - 85
scripts/docs/clean-up-repository.js

@@ -1,85 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* eslint-env node */
-
-'use strict';
-
-/*
-
-This script is to be used on CI to automatically clean up a repository which keeps the project's documentation.
-See: https://github.com/ckeditor/ckeditor5/issues/1392.
-
-*/
-
-// Clean up the repository should be done only for builds on master branch...
-if ( process.env.TRAVIS_BRANCH !== 'master' ) {
-	process.exit();
-}
-
-// ...and when the job was triggered by Cron.
-if ( process.env.TRAVIS_EVENT_TYPE !== 'cron' ) {
-	process.exit();
-}
-
-// Cron which triggered this task is being executed daily.
-// Since we want to clean up the repository one per mounth, we need to add an additional check.
-if ( new Date().getDate() !== 10 ) {
-	process.exit();
-}
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
-const ROOT_PATH = process.cwd();
-const DOCS_PATH = path.join( ROOT_PATH, 'ckeditor5.github.io' );
-
-const mainRepoUrl = 'https://github.com/CKEditor5/ckeditor5.github.io';
-
-// The repository should be already cloned. But if it doesn't, let's clone it again.
-if ( !fs.existsSync( DOCS_PATH ) ) {
-	console.log( 'Cloning ckeditor5.github.io repository...' );
-	exec( `git clone ${ mainRepoUrl }.git` );
-}
-
-// Change work directory in order to make a commit in CKEditor 5 page's repository.
-process.chdir( DOCS_PATH );
-
-exec( `echo "https://${ process.env.GITHUB_TOKEN }:@github.com" > .git/credentials 2> /dev/null` );
-exec( 'git config credential.helper "store --file=.git/credentials"' );
-
-// Copy a commit which will be a new root in the repository.
-const commit = exec( 'git log --oneline --reverse -5 --format="%h" | head -n 1' ).trim();
-
-// Checkout to the status of the git repo at commit. Create a temporary branch.
-exec( `git checkout --orphan temp ${ commit }` );
-
-// Create a new commit that is to be the new root commit.
-exec( 'git commit -m "Documentation build."' );
-
-// Rebase the part of history from <commit> to master on the temporary branch.
-exec( `git rebase --onto temp ${ commit } master` );
-
-// Remove the temporary branch.
-exec( 'git branch -D temp' );
-
-// Pray.
-exec( 'git push -f' );
-
-// Change work directory to the previous value.
-process.chdir( ROOT_PATH );
-
-function exec( command ) {
-	try {
-		return tools.shExec( command, { verbosity: 'error' } );
-	}
-	catch ( error ) {
-		console.error( error );
-
-		process.exit( 1 );
-	}
-}