Compare commits

..

7 Commits

Author SHA1 Message Date
peaceiris
51a5b047a7 docs: fix
Some checks failed
docker image ci / test (push) Has been cancelled
docker image ci / shellcheck (push) Has been cancelled
docker image ci / hadolint (push) Has been cancelled
2019-09-25 02:47:12 +09:00
peaceiris
649380ea44 docs: update TOC 2019-09-25 02:46:13 +09:00
peaceiris
493f73c406 fix: avoid #29 2019-09-25 02:43:21 +09:00
Roman Hotsiy
8eedda6921 feat: new option keepFiles (#33) 2019-09-25 02:41:21 +09:00
peaceiris
13d694636e docs: Add submodules to actions/checkout
https://github.com/peaceiris/actions-hugo/issues/42
2019-09-24 07:29:34 +09:00
peaceiris
551961e807 gha: remove paths 2019-09-23 14:36:00 +09:00
peaceiris
3e09c28a79 docs: update tag 2019-09-23 14:07:50 +09:00
4 changed files with 43 additions and 18 deletions

View File

@@ -4,12 +4,6 @@ on:
pull_request:
types: [opened, synchronize]
push:
paths:
- '**'
- '.**'
- '!LICENSE'
- '!README.md'
- '!images'
jobs:
test:

View File

@@ -28,6 +28,7 @@ Table of Contents
- [⭐️ `PERSONAL_TOKEN`](#%EF%B8%8F-personal_token)
- [⭐️ `GITHUB_TOKEN`](#%EF%B8%8F-github_token)
- [⭐️ Suppressing empty commits](#%EF%B8%8F-suppressing-empty-commits)
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
- [Tips and FAQ](#tips-and-faq)
- [How to add `CNAME`](#how-to-add-cname)
- [Deployment completed but you cannot read](#deployment-completed-but-you-cannot-read)
@@ -96,17 +97,19 @@ jobs:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
# with:
# submodules: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.0
with:
hugo-version: '0.58.2'
hugo-version: '0.58.3'
- name: Build
run: hugo --gc --minify --cleanDestinationDir
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -150,8 +153,8 @@ You can pull a public docker image from Docker Hub.
By pulling docker images, you can reduce the overall execution time of your workflow. In addition, `latest` tag is provided.
```diff
- uses: peaceiris/actions-gh-pages@v2.3.1
+ uses: docker://peaceiris/gh-pages:v2.3.1
- uses: peaceiris/actions-gh-pages@v2.3.2
+ uses: docker://peaceiris/gh-pages:v2.3.2
```
- [peaceiris/gh-pages - Docker Hub](https://hub.docker.com/r/peaceiris/gh-pages)
@@ -187,8 +190,8 @@ By default, a commit will always be generated and pushed to the `PUBLISH_BRANCH`
For example:
```yaml
- name: deploy
uses: peaceiris/actions-gh-pages@v2.3.1
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -197,6 +200,24 @@ For example:
emptyCommits: false
```
#### ⭐️ Keeping existing files
By default, existing files in the publish branch are removed before adding the ones from publish dir. If you want the action to add new files but leave existing ones untouched, set the optional parameter `keepFiles` to `true`.
For example:
```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
with:
keepFiles: true
```
## Tips and FAQ
@@ -260,7 +281,7 @@ jobs:
npm run build
- name: deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -308,7 +329,7 @@ jobs:
run: npm run build
- name: deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -358,7 +379,7 @@ jobs:
run: touch ./out/.nojekyll
- name: deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -405,7 +426,7 @@ jobs:
run: npm run generate
- name: deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
@@ -453,7 +474,7 @@ jobs:
run: mkdocs build
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.3.1
uses: peaceiris/actions-gh-pages@v2.3.2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages

View File

@@ -12,3 +12,7 @@ inputs:
description: 'If empty commits should be made to the publication branch'
required: false
default: 'true'
keepFiles:
description: 'If existing files in the publish branch should be not removed before deploying'
required: false
default: 'false'

View File

@@ -61,7 +61,13 @@ remote_branch="${PUBLISH_BRANCH}"
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)"
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
cd "${local_dir}"
git rm -r --ignore-unmatch '*'
if [[ ${INPUT_KEEPFILES} == "true" ]]; then
print_info "Keeping existing files: ${INPUT_KEEPFILES}"
else
git rm -r --ignore-unmatch '*'
fi
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \
tail -n +2 | \
xargs -I % cp -rf % "${local_dir}/"