Compare commits
6 Commits
v2.3.2-rc2
...
v2.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
380b190669 | ||
|
|
8eedda6921 | ||
|
|
13d694636e | ||
|
|
551961e807 | ||
|
|
3e09c28a79 | ||
|
|
8f168fea5a |
13
.github/workflows/docker-image-ci.yml
vendored
13
.github/workflows/docker-image-ci.yml
vendored
@@ -1,12 +1,9 @@
|
|||||||
name: docker image ci
|
name: docker image ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize]
|
||||||
push:
|
push:
|
||||||
paths:
|
|
||||||
- '**'
|
|
||||||
- '!LICENSE'
|
|
||||||
- '!README.md'
|
|
||||||
- '!images'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -14,6 +11,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
env:
|
env:
|
||||||
@@ -26,6 +25,8 @@ jobs:
|
|||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
- name: shellcheck
|
- name: shellcheck
|
||||||
run: shellcheck ./entrypoint.sh
|
run: shellcheck ./entrypoint.sh
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ jobs:
|
|||||||
runs-on: macOS-10.14
|
runs-on: macOS-10.14
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
- name: hadolint
|
- name: hadolint
|
||||||
run: |
|
run: |
|
||||||
brew install hadolint
|
brew install hadolint
|
||||||
|
|||||||
43
README.md
43
README.md
@@ -28,6 +28,7 @@ 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)
|
||||||
- [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 +97,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.0
|
||||||
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 +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.
|
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 +190,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 +200,24 @@ 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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Tips and FAQ
|
## Tips and FAQ
|
||||||
|
|
||||||
@@ -260,7 +281,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 +329,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 +379,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 +426,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 +474,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'
|
||||||
@@ -11,6 +11,11 @@ function print_info() {
|
|||||||
echo -e "\e[36mINFO: ${1}\e[m"
|
echo -e "\e[36mINFO: ${1}\e[m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function skip() {
|
||||||
|
print_info "No changes detected, skipping deployment"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# check values
|
# check values
|
||||||
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
|
if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
|
||||||
|
|
||||||
@@ -32,6 +37,7 @@ elif [ -n "${PERSONAL_TOKEN}" ]; then
|
|||||||
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"
|
||||||
|
|
||||||
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
|
|
||||||
@@ -55,7 +61,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}/"
|
||||||
@@ -74,12 +86,10 @@ git add --all
|
|||||||
|
|
||||||
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
|
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
|
||||||
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
|
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
|
||||||
if [[ ${INPUT_EMPTYCOMMITS} == "true" ]]; then
|
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
|
||||||
git commit --allow-empty -m "${COMMIT_MESSAGE}"
|
git commit -m "${COMMIT_MESSAGE}" || skip
|
||||||
else
|
else
|
||||||
git commit -m "${COMMIT_MESSAGE}" || \
|
git commit --allow-empty -m "${COMMIT_MESSAGE}"
|
||||||
print_info "No changes detected, skipping deployment" && \
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git push origin "${remote_branch}"
|
git push origin "${remote_branch}"
|
||||||
|
|||||||
Reference in New Issue
Block a user