Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crazy-max/ghaction-github-pages
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dev
Choose a base ref
...
head repository: python-gino/ghaction-github-pages
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 27, 2019

  1. add target_path

    fantix committed Dec 27, 2019
    Copy the full SHA
    182a455 View commit details

Commits on Dec 30, 2019

  1. add status debug

    fantix committed Dec 30, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    pietroalbini Pietro Albini
    Copy the full SHA
    0152314 View commit details

Commits on May 1, 2020

  1. Copy the full SHA
    ac2d0b0 View commit details
  2. bugfix: not include .html

    fantix committed May 1, 2020
    Copy the full SHA
    a2c933d View commit details

Commits on May 6, 2020

  1. support v1.0.x -> 1.0

    fantix committed May 6, 2020
    Copy the full SHA
    fcc82b5 View commit details
Showing with 58 additions and 7 deletions.
  1. +2 −0 action.yml
  2. +24 −3 lib/main.js
  3. +32 −4 src/main.ts
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ inputs:
target_branch:
description: 'Git branch where assets will be deployed'
default: 'gh-pages'
target_path:
description: 'Path in the target repository to deploy'
keep_history:
description: 'Create incremental commit instead of doing push force'
default: 'false'
27 changes: 24 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ function run() {
try {
const repo = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
const target_branch = core.getInput('target_branch') || 'gh-pages';
const target_path = core.getInput('target_path') || '.';
const keep_history = /true/i.test(core.getInput('keep_history'));
const allow_empty_commit = /true/i.test(core.getInput('allow_empty_commit'));
const build_dir = core.getInput('build_dir', { required: true });
@@ -66,12 +67,27 @@ function run() {
yield exec.exec('git', ['init', '.']);
yield exec.exec('git', ['checkout', '--orphan', target_branch]);
}
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir);
let target = path.join(tmpdir, ...target_path
.split('/')
.filter(x => !['refs', 'tags', 'heads'].includes(x))
.map(x => x.replace(/v(\d+)\.(\d+)\.([\dx]+)/, '$1.$2')));
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${target}`);
fs_extra_1.ensureDirSync(target);
fs_extra_1.copySync(path.join(currentdir, build_dir), target);
if (fqdn) {
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`);
fs.writeFileSync(path.join(tmpdir, 'CNAME'), fqdn.trim());
}
// update versions.json
let versions = {};
fs.readdirSync(path.join(tmpdir, 'docs')).forEach(loc => {
if (!loc.endsWith('html') && !loc.endsWith('json'))
versions[loc] = fs
.readdirSync(path.join(tmpdir, 'docs', loc))
.filter(x => !x.endsWith('html'))
.sort();
});
fs.writeFileSync(path.join(tmpdir, 'docs', 'versions.json'), JSON.stringify(versions));
core.info(`🔨 Configuring git committer to be ${committer_name} <${committer_email}>`);
yield exec.exec('git', ['config', 'user.name', committer_name]);
yield exec.exec('git', ['config', 'user.email', committer_email]);
@@ -82,14 +98,19 @@ function run() {
core.info('⚠️ Nothing to deploy');
return;
}
yield exec.exec('git', ['status']);
yield exec.exec('git', ['add', '--all', '.']);
let gitCommitCmd = [];
gitCommitCmd.push('commit');
if (allow_empty_commit) {
core.info(`✅ Allow empty commit`);
gitCommitCmd.push('--allow-empty');
}
gitCommitCmd.push('-m', commit_message);
gitCommitCmd.push('-m', commit_message
.split('/')
.filter(x => !['refs', 'tags', 'heads'].includes(x))
.map(x => x.replace(/v(\d+)\.(\d+)\.([\dx]+)/, '$1.$2'))
.join('/'));
yield exec.exec('git', gitCommitCmd);
yield exec.exec('git', ['show', '--stat-count=10', 'HEAD']);
let gitPushCmd = [];
36 changes: 32 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as child_process from 'child_process';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {copySync} from 'fs-extra';
import {copySync, ensureDirSync} from 'fs-extra';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
@@ -10,6 +10,7 @@ async function run() {
try {
const repo: string = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
const target_branch: string = core.getInput('target_branch') || 'gh-pages';
const target_path: string = core.getInput('target_path') || '.';
const keep_history: boolean = /true/i.test(core.getInput('keep_history'));
const allow_empty_commit: boolean = /true/i.test(core.getInput('allow_empty_commit'));
const build_dir: string = core.getInput('build_dir', {required: true});
@@ -51,14 +52,33 @@ async function run() {
await exec.exec('git', ['checkout', '--orphan', target_branch]);
}

core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
copySync(path.join(currentdir, build_dir), tmpdir);
let target = path.join(
tmpdir,
...target_path
.split('/')
.filter(x => !['refs', 'tags', 'heads'].includes(x))
.map(x => x.replace(/v(\d+)\.(\d+)\.([\dx]+)/, '$1.$2'))
);
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${target}`);
ensureDirSync(target);
copySync(path.join(currentdir, build_dir), target);

if (fqdn) {
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`);
fs.writeFileSync(path.join(tmpdir, 'CNAME'), fqdn.trim());
}

// update versions.json
let versions = {};
fs.readdirSync(path.join(tmpdir, 'docs')).forEach(loc => {
if (!loc.endsWith('html') && !loc.endsWith('json'))
versions[loc] = fs
.readdirSync(path.join(tmpdir, 'docs', loc))
.filter(x => !x.endsWith('html'))
.sort();
});
fs.writeFileSync(path.join(tmpdir, 'docs', 'versions.json'), JSON.stringify(versions));

core.info(`🔨 Configuring git committer to be ${committer_name} <${committer_email}>`);
await exec.exec('git', ['config', 'user.name', committer_name]);
await exec.exec('git', ['config', 'user.email', committer_email]);
@@ -70,6 +90,7 @@ async function run() {
return;
}

await exec.exec('git', ['status']);
await exec.exec('git', ['add', '--all', '.']);

let gitCommitCmd: Array<string> = [];
@@ -78,7 +99,14 @@ async function run() {
core.info(`✅ Allow empty commit`);
gitCommitCmd.push('--allow-empty');
}
gitCommitCmd.push('-m', commit_message);
gitCommitCmd.push(
'-m',
commit_message
.split('/')
.filter(x => !['refs', 'tags', 'heads'].includes(x))
.map(x => x.replace(/v(\d+)\.(\d+)\.([\dx]+)/, '$1.$2'))
.join('/')
);
await exec.exec('git', gitCommitCmd);

await exec.exec('git', ['show', '--stat-count=10', 'HEAD']);