Compare commits

...

19 Commits

Author SHA1 Message Date
peaceiris
354d78ff6f chore(release): 3.0.3
Some checks failed
Release / release (push) Has been cancelled
2020-02-06 15:40:04 +09:00
peaceiris
7605281c4b chore(release): Add build assets 2020-02-06 15:40:03 +09:00
peaceiris
2948e5eda8 docs: update example of publish_branch 2020-02-06 15:39:37 +09:00
peaceiris
e8d0817a48 chore(release): Remove build assets [skip ci] 2020-02-06 15:22:10 +09:00
peaceiris
9d8382b381 chore(release): 3.0.3-0
Some checks failed
Release / release (push) Has been cancelled
2020-02-06 15:22:10 +09:00
peaceiris
8ccc2d9608 chore(release): Add build assets 2020-02-06 15:22:08 +09:00
Shohei Ueda
1b6740cb30 fix: Enable to create branch for first deployment (#92)
* fix: Enable to create branch for first deployment
* fix: remove pull_request

* ci: remove lint-staged husky for testing
* ci: Add git checkout {package-lock,package}.json
2020-02-06 15:21:18 +09:00
peaceiris
479c59e6d2 chore(release): Remove build assets [skip ci] 2020-02-06 01:55:56 +09:00
peaceiris
a22f6fc3b7 chore(release): 3.0.2
Some checks failed
Release / release (push) Has been cancelled
2020-02-06 01:55:55 +09:00
peaceiris
f28cc017a9 chore(release): Add build assets 2020-02-06 01:55:54 +09:00
peaceiris
f8b5a36401 fix: add filePath 2020-02-06 01:52:45 +09:00
peaceiris
848165cf9f fix: copy force 2020-02-06 01:50:30 +09:00
peaceiris
fb54d6af4d fix: add debug 2020-02-06 01:41:17 +09:00
peaceiris
6edc4c9764 fix: copy directories #89 2020-02-06 01:38:12 +09:00
peaceiris
d35854bdf8 docs: update log example for v3 2020-02-05 20:38:55 +09:00
peaceiris
f0177d176f docs: Add Supported Platforms table 2020-02-05 20:32:49 +09:00
peaceiris
0ba5bf3eeb docs: Add CodeFactor badge 2020-02-05 20:26:02 +09:00
peaceiris
cfdf8c43ed ci: use github_token for windows-latest 2020-02-05 20:11:40 +09:00
peaceiris
ce8c273a61 chore(release): Remove build assets [skip ci] 2020-02-05 20:06:02 +09:00
9 changed files with 170 additions and 2235 deletions

View File

@@ -30,7 +30,6 @@ jobs:
- 'macos-latest' - 'macos-latest'
- 'windows-latest' - 'windows-latest'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Read .nvmrc - name: Read .nvmrc
@@ -43,6 +42,12 @@ jobs:
node-version: '${{ steps.nvm.outputs.NVMRC }}' node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm ci - run: npm ci
- name: Remove lint-staged husky
run: |
npm uninstall lint-staged husky
git checkout package-lock.json package.json
- run: npm run build - run: npm run build
- name: Setup mdBook - name: Setup mdBook
@@ -63,6 +68,7 @@ jobs:
echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}" echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}"
- name: Deploy - name: Deploy
if: matrix.os != 'windows-latest'
uses: ./ uses: ./
with: with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
@@ -79,9 +85,21 @@ jobs:
# tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }} # tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
# tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}' # tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
# - name: Deploy v2 - name: Deploy
# uses: peaceiris/actions-gh-pages@v2 if: matrix.os == 'windows-latest'
# env: uses: ./
# ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }} with:
# PUBLISH_BRANCH: gh-pages # deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# PUBLISH_DIR: ./test_projects/mdbook/book github_token: ${{ secrets.GITHUB_TOKEN }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
# publish_branch: gh-pages
publish_dir: ./test_projects/mdbook/book
# external_repository: ''
allow_empty_commit: true
# keep_files: true
# force_orphan: true
# user_name: iris
# user_email: email@peaceiris.com
# commit_message: ${{ github.event.head_commit.message }}
# tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
# tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'

View File

@@ -2,6 +2,46 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [3.0.3](https://github.com/peaceiris/actions-gh-pages/compare/v3.0.3-0...v3.0.3) (2020-02-06)
### docs
* update example of publish_branch ([2948e5e](https://github.com/peaceiris/actions-gh-pages/commit/2948e5eda85d99ffc20cda677353918ea9ea3f45))
## [3.0.3-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.0.2...v3.0.3-0) (2020-02-06)
### fix
* Enable to create branch for first deployment (#92) ([1b6740c](https://github.com/peaceiris/actions-gh-pages/commit/1b6740cb30fc6a5a695a015144589862eb241b7d)), closes [#92](https://github.com/peaceiris/actions-gh-pages/issues/92)
## [3.0.2](https://github.com/peaceiris/actions-gh-pages/compare/v3.0.1...v3.0.2) (2020-02-05)
### ci
* use github_token for windows-latest ([cfdf8c4](https://github.com/peaceiris/actions-gh-pages/commit/cfdf8c43ed170ce3bcfc1b4ee5ba50000e89f9e7))
### docs
* Add CodeFactor badge ([0ba5bf3](https://github.com/peaceiris/actions-gh-pages/commit/0ba5bf3eeb5f0ad9e42dc6344afa736b47dac67f))
* Add Supported Platforms table ([f0177d1](https://github.com/peaceiris/actions-gh-pages/commit/f0177d176f9464c11cbdff5a68dbecd6e630e371))
* update log example for v3 ([d35854b](https://github.com/peaceiris/actions-gh-pages/commit/d35854bdf87ba4311c5b5ba738260e4eb89c2295))
### fix
* add debug ([fb54d6a](https://github.com/peaceiris/actions-gh-pages/commit/fb54d6af4d2abbf7a42806620594b173c2f55882))
* add filePath ([f8b5a36](https://github.com/peaceiris/actions-gh-pages/commit/f8b5a36401de48c3bf2fda47a51b010350405163))
* copy directories #89 ([6edc4c9](https://github.com/peaceiris/actions-gh-pages/commit/6edc4c976449147551137b19eb7bc092d9d129ec)), closes [#89](https://github.com/peaceiris/actions-gh-pages/issues/89)
* copy force ([848165c](https://github.com/peaceiris/actions-gh-pages/commit/848165cf9f01c61b1f2e83d433177a9f46ce5ea7))
## [3.0.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.0.0...v3.0.1) (2020-02-05) ## [3.0.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.0.0...v3.0.1) (2020-02-05)

View File

@@ -2,6 +2,7 @@
[![release](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases/latest) [![release](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases/latest)
[![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases) [![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases)
![Test Action](https://github.com/peaceiris/actions-gh-pages/workflows/Test%20Action/badge.svg?branch=master&event=push) ![Test Action](https://github.com/peaceiris/actions-gh-pages/workflows/Test%20Action/badge.svg?branch=master&event=push)
[![CodeFactor](https://www.codefactor.io/repository/github/peaceiris/actions-gh-pages/badge)](https://www.codefactor.io/repository/github/peaceiris/actions-gh-pages)
[![Release Feed](https://img.shields.io/badge/release-feed-yellow)](https://github.com/peaceiris/actions-gh-pages/releases.atom) [![Release Feed](https://img.shields.io/badge/release-feed-yellow)](https://github.com/peaceiris/actions-gh-pages/releases.atom)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=peaceiris/actions-gh-pages)](https://dependabot.com) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=peaceiris/actions-gh-pages)](https://dependabot.com)
@@ -33,6 +34,8 @@ The next example step will deploy `./public` directory to the remote `gh-pages`
publish_dir: ./public publish_dir: ./public
``` ```
### Supported Tokens
Three tokens are supported. Three tokens are supported.
| Token | Private repo | Public repo | Protocol | Setup | | Token | Private repo | Public repo | Protocol | Setup |
@@ -43,6 +46,16 @@ Three tokens are supported.
1. Currently, GitHub Actions does not support to trigger a GitHub Pages build event using GITHUB_TOKEN on a public repository. 1. Currently, GitHub Actions does not support to trigger a GitHub Pages build event using GITHUB_TOKEN on a public repository.
### Supported Platforms
| runs-on | `deploy_key` | `github_token` | `personal_token` |
|---|:---:|:---:|:---:|
| ubuntu-18.04 | ✅️ | ✅️ | ✅️ |
| macos-latest | ✅️ | ✅️ | ✅️ |
| windows-latest | (2) | ✅️ | ✅️ |
2. WIP, See [Issue #87](https://github.com/peaceiris/actions-gh-pages/issues/87)
## Table of Contents ## Table of Contents
@@ -136,7 +149,7 @@ on:
- master - master
jobs: jobs:
build-deploy: deploy:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
@@ -173,13 +186,28 @@ The above example is for [Project Pages sites]. (`<username>/<project_name>` rep
For [User and Organization Pages sites] (`<username>/<username>.github.io` repository), For [User and Organization Pages sites] (`<username>/<username>.github.io` repository),
we have to set `master` branch to `PUBLISH_BRANCH`. we have to set `master` branch to `PUBLISH_BRANCH`.
A default value of `publish_branch` is `gh-pages`.
```yaml ```yaml
on: on:
push: push:
branches: branches:
- source # default branch - source # default branch
publish_branch: master # deploying branch jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: somebuild
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./public
publish_branch: master # deploying branch
``` ```
[Project Pages sites]: https://help.github.com/en/articles/user-organization-and-project-pages#project-pages-sites [Project Pages sites]: https://help.github.com/en/articles/user-organization-and-project-pages#project-pages-sites

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 78 KiB

File diff suppressed because it is too large Load Diff

19
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "actions-github-pages", "name": "actions-github-pages",
"version": "3.0.1", "version": "3.0.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -27,15 +27,6 @@
"@octokit/rest": "^16.15.0" "@octokit/rest": "^16.15.0"
} }
}, },
"@actions/glob": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.0.tgz",
"integrity": "sha512-lx8SzyQ2FE9+UUvjqY1f28QbTJv+w8qP7kHHbfQRhphrlcx0Mdmm1tZdGJzfxv1jxREa/sLW4Oy8CbGQKCJySA==",
"requires": {
"@actions/core": "^1.2.0",
"minimatch": "^3.0.4"
}
},
"@actions/http-client": { "@actions/http-client": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.6.tgz", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.6.tgz",
@@ -1136,7 +1127,8 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
}, },
"base": { "base": {
"version": "0.11.2", "version": "0.11.2",
@@ -1217,6 +1209,7 @@
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -1578,7 +1571,8 @@
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
}, },
"concat-stream": { "concat-stream": {
"version": "2.0.0", "version": "2.0.0",
@@ -5265,6 +5259,7 @@
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "actions-github-pages", "name": "actions-github-pages",
"version": "3.0.1", "version": "3.0.3",
"description": "GitHub Actions for GitHub Pages", "description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js", "main": "lib/index.js",
"engines": { "engines": {
@@ -53,7 +53,6 @@
"@actions/core": "^1.2.2", "@actions/core": "^1.2.2",
"@actions/exec": "^1.0.3", "@actions/exec": "^1.0.3",
"@actions/github": "^2.1.0", "@actions/github": "^2.1.0",
"@actions/glob": "^0.1.0",
"@actions/io": "^1.0.2" "@actions/io": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -2,8 +2,8 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as github from '@actions/github'; import * as github from '@actions/github';
import * as io from '@actions/io'; import * as io from '@actions/io';
import * as glob from '@actions/glob';
import path from 'path'; import path from 'path';
import fs from 'fs';
import {Inputs, CmdResult} from './interfaces'; import {Inputs, CmdResult} from './interfaces';
import {getHomeDir} from './utils'; import {getHomeDir} from './utils';
@@ -23,13 +23,15 @@ export async function copyAssets(
publishDir: string, publishDir: string,
workDir: string workDir: string
): Promise<void> { ): Promise<void> {
const copyOpts = {recursive: true, force: false}; const copyOpts = {recursive: true, force: true};
const globber = await glob.create(`${publishDir}/*`); const files = fs.readdirSync(publishDir);
for await (const file of globber.globGenerator()) { core.debug(`${files}`);
for await (const file of files) {
if (file.endsWith('.git') || file.endsWith('.github')) { if (file.endsWith('.git') || file.endsWith('.github')) {
continue; continue;
} }
await io.cp(file, `${workDir}/`, copyOpts); const filePath = path.join(publishDir, file);
await io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`); core.info(`[INFO] copy ${file}`);
} }
@@ -63,36 +65,41 @@ export async function setRepo(inps: Inputs, remoteURL: string): Promise<void> {
} }
} }
}; };
result.exitcode = await exec.exec(
'git',
[
'clone',
'--depth=1',
'--single-branch',
'--branch',
inps.PublishBranch,
remoteURL,
workDir
],
options
);
process.chdir(workDir); try {
result.exitcode = await exec.exec(
'git',
[
'clone',
'--depth=1',
'--single-branch',
'--branch',
inps.PublishBranch,
remoteURL,
workDir
],
options
);
if (result.exitcode === 0) {
process.chdir(workDir);
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}
if (result.exitcode === 0) { await copyAssets(publishDir, workDir);
if (inps.KeepFiles) { return;
core.info('[INFO] Keep existing files');
} else { } else {
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']); throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
} }
} catch (e) {
await copyAssets(publishDir, workDir);
return;
} else {
core.info( core.info(
`[INFO] first deployment, create new branch ${inps.PublishBranch}` `[INFO] first deployment, create new branch ${inps.PublishBranch}`
); );
core.info(e);
await createWorkDir(workDir); await createWorkDir(workDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch); await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, workDir); await copyAssets(publishDir, workDir);
return; return;

View File

@@ -100,9 +100,6 @@ export async function setGithubToken(
`You deploy from ${inps.PublishBranch} to ${inps.PublishBranch}` `You deploy from ${inps.PublishBranch} to ${inps.PublishBranch}`
); );
} }
} else if (context.eventName === 'pull_request') {
// TODO: support pull_request event
throw new Error('This action does not support pull_request event now.');
} }
const isPrivateRepository = payload.repository?.private; const isPrivateRepository = payload.repository?.private;