Compare commits
14 Commits
v2.3.2
...
v2.5.0-rc0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2485261a06 | ||
|
|
954d420fb6 | ||
|
|
34d447917a | ||
|
|
aee95e5b5e | ||
|
|
6ea8776db8 | ||
|
|
60eb903bb7 | ||
|
|
da0488f27e | ||
|
|
fd120a1d22 | ||
|
|
83bc08b934 | ||
|
|
380b190669 | ||
|
|
8eedda6921 | ||
|
|
13d694636e | ||
|
|
551961e807 | ||
|
|
3e09c28a79 |
6
.github/workflows/docker-image-ci.yml
vendored
6
.github/workflows/docker-image-ci.yml
vendored
@@ -4,12 +4,6 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
push:
|
push:
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '.**'
|
|
||||||
- '!LICENSE'
|
|
||||||
- '!README.md'
|
|
||||||
- '!images'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
66
README.md
66
README.md
@@ -28,6 +28,8 @@ Table of Contents
|
|||||||
- [⭐️ `PERSONAL_TOKEN`](#%EF%B8%8F-personal_token)
|
- [⭐️ `PERSONAL_TOKEN`](#%EF%B8%8F-personal_token)
|
||||||
- [⭐️ `GITHUB_TOKEN`](#%EF%B8%8F-github_token)
|
- [⭐️ `GITHUB_TOKEN`](#%EF%B8%8F-github_token)
|
||||||
- [⭐️ Suppressing empty commits](#%EF%B8%8F-suppressing-empty-commits)
|
- [⭐️ Suppressing empty commits](#%EF%B8%8F-suppressing-empty-commits)
|
||||||
|
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
|
||||||
|
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
|
||||||
- [Tips and FAQ](#tips-and-faq)
|
- [Tips and FAQ](#tips-and-faq)
|
||||||
- [How to add `CNAME`](#how-to-add-cname)
|
- [How to add `CNAME`](#how-to-add-cname)
|
||||||
- [Deployment completed but you cannot read](#deployment-completed-but-you-cannot-read)
|
- [Deployment completed but you cannot read](#deployment-completed-but-you-cannot-read)
|
||||||
@@ -96,17 +98,19 @@ jobs:
|
|||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
# with:
|
||||||
|
# submodules: true
|
||||||
|
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
uses: peaceiris/actions-hugo@v2.2.0
|
uses: peaceiris/actions-hugo@v2.2.1
|
||||||
with:
|
with:
|
||||||
hugo-version: '0.58.2'
|
hugo-version: '0.58.3'
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: hugo --gc --minify --cleanDestinationDir
|
run: hugo --gc --minify --cleanDestinationDir
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -150,8 +154,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.
|
By pulling docker images, you can reduce the overall execution time of your workflow. In addition, `latest` tag is provided.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- uses: peaceiris/actions-gh-pages@v2.3.1
|
- uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
+ uses: docker://peaceiris/gh-pages:v2.3.1
|
+ uses: docker://peaceiris/gh-pages:v2.4.0
|
||||||
```
|
```
|
||||||
|
|
||||||
- [peaceiris/gh-pages - Docker Hub](https://hub.docker.com/r/peaceiris/gh-pages)
|
- [peaceiris/gh-pages - Docker Hub](https://hub.docker.com/r/peaceiris/gh-pages)
|
||||||
@@ -187,8 +191,8 @@ By default, a commit will always be generated and pushed to the `PUBLISH_BRANCH`
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -197,6 +201,44 @@ For example:
|
|||||||
emptyCommits: false
|
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.4.0
|
||||||
|
env:
|
||||||
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
|
PUBLISH_BRANCH: gh-pages
|
||||||
|
PUBLISH_DIR: ./public
|
||||||
|
with:
|
||||||
|
keepFiles: true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### ⭐️ Deploy to external repository
|
||||||
|
|
||||||
|
By default, your files are published to the repository which is running this action. If you want to publish to another repository on GitHub, set the environment variable `EXTERNAL_REPOSITORY` to `<username>/<external-repository>`.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
|
env:
|
||||||
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
|
EXTERNAL_REPOSITORY: username/username.github.io
|
||||||
|
PUBLISH_BRANCH: master
|
||||||
|
PUBLISH_DIR: ./public
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use `ACTIONS_DEPLOY_KEY` or `PERSONAL_TOKEN`. When you use `ACTIONS_DEPLOY_KEY`, set your private key to the repository which includes this action and set your public key to your external repository.
|
||||||
|
|
||||||
|
Be careful, `GITHUB_TOKEN` has no permission to access to external repositories.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Tips and FAQ
|
## Tips and FAQ
|
||||||
|
|
||||||
@@ -260,7 +302,7 @@ jobs:
|
|||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -308,7 +350,7 @@ jobs:
|
|||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -358,7 +400,7 @@ jobs:
|
|||||||
run: touch ./out/.nojekyll
|
run: touch ./out/.nojekyll
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -405,7 +447,7 @@ jobs:
|
|||||||
run: npm run generate
|
run: npm run generate
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -453,7 +495,7 @@ jobs:
|
|||||||
run: mkdocs build
|
run: mkdocs build
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.1
|
uses: peaceiris/actions-gh-pages@v2.4.0
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
|
|||||||
@@ -12,3 +12,7 @@ inputs:
|
|||||||
description: 'If empty commits should be made to the publication branch'
|
description: 'If empty commits should be made to the publication branch'
|
||||||
required: false
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
keepFiles:
|
||||||
|
description: 'If existing files in the publish branch should be not removed before deploying'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
@@ -17,6 +17,13 @@ function skip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# check values
|
# check values
|
||||||
|
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
|
||||||
|
PUBLISH_REPOSITORY=${EXTERNAL_REPOSITORY}
|
||||||
|
else
|
||||||
|
PUBLISH_REPOSITORY=${GITHUB_REPOSITORY}
|
||||||
|
fi
|
||||||
|
print_info "Deploy to ${PUBLISH_REPOSITORY}"
|
||||||
|
|
||||||
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
|
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
|
||||||
|
|
||||||
print_info "setup with ACTIONS_DEPLOY_KEY"
|
print_info "setup with ACTIONS_DEPLOY_KEY"
|
||||||
@@ -26,20 +33,25 @@ if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
|
|||||||
echo "${ACTIONS_DEPLOY_KEY}" > /root/.ssh/id_rsa
|
echo "${ACTIONS_DEPLOY_KEY}" > /root/.ssh/id_rsa
|
||||||
chmod 400 /root/.ssh/id_rsa
|
chmod 400 /root/.ssh/id_rsa
|
||||||
|
|
||||||
remote_repo="git@github.com:${GITHUB_REPOSITORY}.git"
|
remote_repo="git@github.com:${PUBLISH_REPOSITORY}.git"
|
||||||
|
|
||||||
elif [ -n "${PERSONAL_TOKEN}" ]; then
|
elif [ -n "${PERSONAL_TOKEN}" ]; then
|
||||||
|
|
||||||
print_info "setup with PERSONAL_TOKEN"
|
print_info "setup with PERSONAL_TOKEN"
|
||||||
|
|
||||||
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@github.com/${PUBLISH_REPOSITORY}.git"
|
||||||
|
|
||||||
elif [ -n "${GITHUB_TOKEN}" ]; then
|
elif [ -n "${GITHUB_TOKEN}" ]; then
|
||||||
|
|
||||||
print_info "setup with GITHUB_TOKEN"
|
print_info "setup with GITHUB_TOKEN"
|
||||||
print_error "Do not use GITHUB_TOKEN, See #9"
|
print_error "Do not use GITHUB_TOKEN, See #9"
|
||||||
|
|
||||||
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
|
||||||
|
print_error "can not use GITHUB_TOKEN to deploy to a external repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${PUBLISH_REPOSITORY}.git"
|
||||||
|
|
||||||
else
|
else
|
||||||
print_error "not found ACTIONS_DEPLOY_KEY, PERSONAL_TOKEN, or GITHUB_TOKEN"
|
print_error "not found ACTIONS_DEPLOY_KEY, PERSONAL_TOKEN, or GITHUB_TOKEN"
|
||||||
@@ -61,7 +73,13 @@ remote_branch="${PUBLISH_BRANCH}"
|
|||||||
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)"
|
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
|
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
|
||||||
cd "${local_dir}"
|
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 | \
|
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \
|
||||||
tail -n +2 | \
|
tail -n +2 | \
|
||||||
xargs -I % cp -rf % "${local_dir}/"
|
xargs -I % cp -rf % "${local_dir}/"
|
||||||
|
|||||||
Reference in New Issue
Block a user