Transition to GitHub Actions (#136)
* gulpfile.js: fix ESLint warnings * package.json: add shortcut scripts * scripts/games: do a shallow git clone to save time * ci: migrate to GitHub Actions
This commit is contained in:
parent
5dc5d4331a
commit
245eaf7448
|
@ -0,0 +1,44 @@
|
||||||
|
name: Deploy Site
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo '========== Installing gulp & dependencies =========='
|
||||||
|
sudo apt-get install graphicsmagick
|
||||||
|
wget -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.52/hugo_0.52_Linux-64bit.deb
|
||||||
|
sudo dpkg -i hugo.deb
|
||||||
|
yarn install
|
||||||
|
# Install dependencies one-by-one to avoid race-conditions
|
||||||
|
pushd ./scripts/wiki/ && yarn && popd
|
||||||
|
pushd ./scripts/games/ && yarn && popd
|
||||||
|
hugo version
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
TENANT: 'citra'
|
||||||
|
run: |
|
||||||
|
echo '========== Starting gulp deploy task =========='
|
||||||
|
yarn run build
|
||||||
|
- name: Deploy
|
||||||
|
if: ${{ (! github.base_ref) && (github.repository == 'citra-emu/citra-web') }}
|
||||||
|
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||||
|
with:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
REPOSITORY_NAME: CitraBotWeb/CitraBotWeb.github.io
|
||||||
|
BRANCH: master
|
||||||
|
FOLDER: build
|
||||||
|
CLEAN: true
|
||||||
|
SINGLE_COMMIT: true
|
32
.travis.yml
32
.travis.yml
|
@ -1,32 +0,0 @@
|
||||||
# Build status located at https://travis-ci.org/citra-emu/citra-web
|
|
||||||
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "lts/erbium"
|
|
||||||
cache: yarn
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo '========== Updating Yarn ==========================='
|
|
||||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
|
||||||
- echo '========== Installing gulp & dependencies =========='
|
|
||||||
- sudo apt-get install graphicsmagick
|
|
||||||
- wget -O hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.52/hugo_0.52_Linux-64bit.deb
|
|
||||||
- sudo dpkg -i hugo.deb
|
|
||||||
- yarn install
|
|
||||||
|
|
||||||
- echo '========== Starting gulp deploy task =========='
|
|
||||||
- hugo version
|
|
||||||
- yarn run gulp all --production
|
|
||||||
deploy:
|
|
||||||
provider: pages
|
|
||||||
skip_cleanup: true
|
|
||||||
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
|
|
||||||
local_dir: build
|
|
||||||
repo: CitraBotWeb/CitraBotWeb.github.io
|
|
||||||
target_branch: master
|
|
||||||
fqdn: citra-emu.org
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
- citra@citra-emu.org
|
|
111
gulpfile.js
111
gulpfile.js
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-console */
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const util = require('gulp-util');
|
const util = require('gulp-util');
|
||||||
|
@ -11,69 +12,69 @@ const concat = require('gulp-concat');
|
||||||
const imageResize = require('gulp-image-resize');
|
const imageResize = require('gulp-image-resize');
|
||||||
|
|
||||||
gulp.task('scripts:games', function (callback) {
|
gulp.task('scripts:games', function (callback) {
|
||||||
exec(`cd ./scripts/games/ && yarn install && node app.js`, function (err, stdout, stderr) {
|
exec('yarn install && node app.js', { cwd: './scripts/games/' }, function (err, stdout, stderr) {
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.log(stderr);
|
console.log(stderr);
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('scripts:wiki', function (callback) {
|
gulp.task('scripts:wiki', function (callback) {
|
||||||
exec(`cd ./scripts/wiki/ && yarn install && node app.js`, function (err, stdout, stderr) {
|
exec('yarn install && node app.js', { cwd: './scripts/wiki/' }, function (err, stdout, stderr) {
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.log(stderr);
|
console.log(stderr);
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('assets:images', function() {
|
gulp.task('assets:images', function() {
|
||||||
var baseImages = gulp.src(`build/images/*`, {base: './'})
|
var baseImages = gulp.src('build/images/*', {base: './'})
|
||||||
.pipe(gulp.dest('./'));
|
.pipe(gulp.dest('./'));
|
||||||
var jumbotronImages = gulp.src(`build/images/jumbotron/*`, {base: './'})
|
var jumbotronImages = gulp.src('build/images/jumbotron/*', {base: './'})
|
||||||
.pipe(imageResize({ width: 786, height: 471, crop: true }))
|
.pipe(imageResize({ width: 786, height: 471, crop: true }))
|
||||||
.pipe(gulp.dest('./'));
|
.pipe(gulp.dest('./'));
|
||||||
var bannerImages = gulp.src(`build/images/banners/*`, {base: './'})
|
var bannerImages = gulp.src('build/images/banners/*', {base: './'})
|
||||||
.pipe(imageResize({ width: 824, height: 306, crop: false }))
|
.pipe(imageResize({ width: 824, height: 306, crop: false }))
|
||||||
.pipe(gulp.dest('./'));
|
.pipe(gulp.dest('./'));
|
||||||
var boxartImages = gulp.src(`build/images/game/boxart/*`, {base: './'})
|
var boxartImages = gulp.src('build/images/game/boxart/*', {base: './'})
|
||||||
.pipe(imageResize({ width: 328, height: 300, crop: true }))
|
.pipe(imageResize({ width: 328, height: 300, crop: true }))
|
||||||
.pipe(gulp.dest('./'));
|
.pipe(gulp.dest('./'));
|
||||||
var iconImages = gulp.src(`build/images/game/icons/*`, {base: './'})
|
var iconImages = gulp.src('build/images/game/icons/*', {base: './'})
|
||||||
.pipe(imageResize({ width: 48, height: 48, crop: true }))
|
.pipe(imageResize({ width: 48, height: 48, crop: true }))
|
||||||
.pipe(gulp.dest('./'));
|
.pipe(gulp.dest('./'));
|
||||||
var screenshotImages = gulp.src(`build/images/screenshots/*`)
|
var screenshotImages = gulp.src('build/images/screenshots/*')
|
||||||
.pipe(imageResize({ width: 400, height: 240, crop: false }))
|
.pipe(imageResize({ width: 400, height: 240, crop: false }))
|
||||||
.pipe(gulp.dest(`build/images/screenshots/thumbs`));
|
.pipe(gulp.dest('build/images/screenshots/thumbs'));
|
||||||
|
|
||||||
return merge(baseImages, jumbotronImages, bannerImages, boxartImages, iconImages, screenshotImages);
|
return merge(baseImages, jumbotronImages, bannerImages, boxartImages, iconImages, screenshotImages);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('assets:js', function() {
|
gulp.task('assets:js', function() {
|
||||||
return gulp.src(['src/js/**/*.js'])
|
return gulp.src(['src/js/**/*.js'])
|
||||||
.pipe(concat('script.js'))
|
.pipe(concat('script.js'))
|
||||||
.pipe(gulp.dest('build/js'));
|
.pipe(gulp.dest('build/js'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('assets:fonts', function(){
|
gulp.task('assets:fonts', function(){
|
||||||
return gulp.src('./node_modules/bootstrap-sass/assets/fonts/**/*')
|
return gulp.src('./node_modules/bootstrap-sass/assets/fonts/**/*')
|
||||||
.pipe(gulp.dest('build/fonts/'));
|
.pipe(gulp.dest('build/fonts/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('assets:scss', function () {
|
gulp.task('assets:scss', function () {
|
||||||
var postCssOptions = [ cssnano ];
|
var postCssOptions = [ cssnano ];
|
||||||
return gulp.src('src/scss/style.scss')
|
return gulp.src('src/scss/style.scss')
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(postcss(postCssOptions))
|
.pipe(postcss(postCssOptions))
|
||||||
.pipe(gulp.dest('build/css'))
|
.pipe(gulp.dest('build/css'))
|
||||||
.pipe(browserSync.stream());
|
.pipe(browserSync.stream());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('hugo', function (cb) {
|
gulp.task('hugo', function (cb) {
|
||||||
exec('hugo -s ./site/ -d ../build/ -v', function (err, stdout, stderr) {
|
exec('hugo -s ./site/ -d ../build/ -v', function (err, stdout, stderr) {
|
||||||
console.log(stdout);
|
console.log(stdout);
|
||||||
console.log(stderr);
|
console.log(stderr);
|
||||||
cb(err);
|
cb(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('final:serve', function(done) {
|
gulp.task('final:serve', function(done) {
|
||||||
|
@ -90,29 +91,29 @@ gulp.task('final:serve', function(done) {
|
||||||
gulp.watch('site/**/*.md', gulp.series('hugo'));
|
gulp.watch('site/**/*.md', gulp.series('hugo'));
|
||||||
|
|
||||||
gulp.watch('build/**/*').on('change', function(x) {
|
gulp.watch('build/**/*').on('change', function(x) {
|
||||||
browserSync.reload(x);
|
browserSync.reload(x);
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('final:publish', function(done) {
|
gulp.task('final:publish', function(done) {
|
||||||
fs.writeFileSync(`build/CNAME`, `${cname}`);
|
fs.writeFileSync('build/CNAME', `${cname}`);
|
||||||
fs.writeFileSync(`build/robots.txt`, `Sitemap: https://${cname}/sitemap.xml\n\nUser-agent: *`);
|
fs.writeFileSync('build/robots.txt', `Sitemap: https://${cname}/sitemap.xml\n\nUser-agent: *`);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
const cname = 'citra-emu.org';
|
const cname = 'citra-emu.org';
|
||||||
var finalCommand = null;
|
var finalCommand = null;
|
||||||
|
|
||||||
if (util.env.production) {
|
if (util.env.production) {
|
||||||
process.env.HUGO_ENV = 'PRD';
|
process.env.HUGO_ENV = 'PRD';
|
||||||
process.env.HUGO_BASEURL = `https://${cname}`;
|
process.env.HUGO_BASEURL = `https://${cname}`;
|
||||||
finalCommand = 'final:publish';
|
finalCommand = 'final:publish';
|
||||||
} else {
|
} else {
|
||||||
process.env.HUGO_ENV = 'DEV';
|
process.env.HUGO_ENV = 'DEV';
|
||||||
process.env.HUGO_BASEURL = 'http://localhost:3000';
|
process.env.HUGO_BASEURL = 'http://localhost:3000';
|
||||||
finalCommand = 'final:serve';
|
finalCommand = 'final:serve';
|
||||||
}
|
}
|
||||||
|
|
||||||
util.log(`process.env.HUGO_ENV = '${process.env.HUGO_ENV}'`);
|
util.log(`process.env.HUGO_ENV = '${process.env.HUGO_ENV}'`);
|
||||||
|
@ -120,4 +121,4 @@ util.log(`process.env.HUGO_BASEURL = '${process.env.HUGO_BASEURL}'`);
|
||||||
|
|
||||||
gulp.task('default', gulp.series(gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand));
|
gulp.task('default', gulp.series(gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand));
|
||||||
gulp.task('all', gulp.series(gulp.parallel('scripts:games', 'scripts:wiki'), gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand));
|
gulp.task('all', gulp.series(gulp.parallel('scripts:games', 'scripts:wiki'), gulp.parallel('assets:js', 'assets:fonts', 'assets:scss'), 'hugo', 'assets:images', finalCommand));
|
||||||
gulp.task('content', gulp.series('hugo', finalCommand));
|
gulp.task('content', gulp.series('hugo', finalCommand));
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
"description": "The Citra Official Website",
|
"description": "The Citra Official Website",
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp all --production",
|
||||||
|
"serve": "gulp all"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap-sass": "^3.4.1",
|
"bootstrap-sass": "^3.4.1",
|
||||||
"browser-sync": "^2.26.7",
|
"browser-sync": "^2.26.7",
|
||||||
|
|
|
@ -38,7 +38,7 @@ function gitPull(directory, repository) {
|
||||||
} else {
|
} else {
|
||||||
logger.info(`Cloning repository from Github : ${directory}`);
|
logger.info(`Cloning repository from Github : ${directory}`);
|
||||||
logger.info(`git clone ${repository}`);
|
logger.info(`git clone ${repository}`);
|
||||||
exec(`git clone ${repository}`);
|
exec(`git clone --depth=1 ${repository}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue