Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f168fea5a | ||
|
|
5a72c9206d | ||
|
|
b8dd2848eb | ||
|
|
4530dcd167 | ||
|
|
74f032c7e9 | ||
|
|
0713c6cb9c | ||
|
|
c647ffeac6 | ||
|
|
b16172a44d | ||
|
|
4f0ad674b7 | ||
|
|
16fae5a6db | ||
|
|
e46ccd0122 | ||
|
|
087a904156 | ||
|
|
47a6d63ea8 | ||
|
|
201f9af234 |
17
.github/workflows/docker-image-ci.yml
vendored
@@ -1,6 +1,15 @@
|
|||||||
name: docker image ci
|
name: docker image ci
|
||||||
|
|
||||||
on: push
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize]
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**'
|
||||||
|
- '.**'
|
||||||
|
- '!LICENSE'
|
||||||
|
- '!README.md'
|
||||||
|
- '!images'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -8,6 +17,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
env:
|
env:
|
||||||
@@ -20,6 +31,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
|
||||||
|
|
||||||
@@ -27,6 +40,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
|
||||||
|
|||||||
113
README.md
@@ -21,13 +21,16 @@ Table of Contents
|
|||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [(1) Add ssh deploy key](#1-add-ssh-deploy-key)
|
- [(1) Add ssh deploy key](#1-add-ssh-deploy-key)
|
||||||
- [(2) Create `.github/workflows/gh-pages.yml`](#2-create-githubworkflowsgh-pagesyml)
|
- [(2) Create `.github/workflows/gh-pages.yml`](#2-create-githubworkflowsgh-pagesyml)
|
||||||
- [:star: Repository type - Project](#star-repository-type---project)
|
- [⭐️ Repository type - Project](#%EF%B8%8F-repository-type---project)
|
||||||
- [:star: Repository type - User and Organization](#star-repository-type---user-and-organization)
|
- [⭐️ Repository type - User and Organization](#%EF%B8%8F-repository-type---user-and-organization)
|
||||||
- [Options](#options)
|
- [Options](#options)
|
||||||
- [:star: Pull action image from Docker Hub](#star-pull-action-image-from-docker-hub)
|
- [⭐️ Pull action image from Docker Hub](#%EF%B8%8F-pull-action-image-from-docker-hub)
|
||||||
- [:star: `PERSONAL_TOKEN`](#star-personal_token)
|
- [⭐️ `PERSONAL_TOKEN`](#%EF%B8%8F-personal_token)
|
||||||
- [:star: `GITHUB_TOKEN`](#star-github_token)
|
- [⭐️ `GITHUB_TOKEN`](#%EF%B8%8F-github_token)
|
||||||
- [:star: Suppressing empty commits](#star-suppressing-empty-commits)
|
- [⭐️ Suppressing empty commits](#%EF%B8%8F-suppressing-empty-commits)
|
||||||
|
- [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)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Static Site Generators with Node.js](#static-site-generators-with-nodejs)
|
- [Static Site Generators with Node.js](#static-site-generators-with-nodejs)
|
||||||
- [Gatsby](#gatsby)
|
- [Gatsby](#gatsby)
|
||||||
@@ -59,13 +62,21 @@ Next, Go to **Repository Settings**
|
|||||||
- Go to **Deploy Keys** and add your public key with the **Allow write access**
|
- Go to **Deploy Keys** and add your public key with the **Allow write access**
|
||||||
- Go to **Secrets** and add your private key as `ACTIONS_DEPLOY_KEY`
|
- Go to **Secrets** and add your private key as `ACTIONS_DEPLOY_KEY`
|
||||||
|
|
||||||
|
| Add your public key | Success |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Add your private key | Success |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
### (2) Create `.github/workflows/gh-pages.yml`
|
### (2) Create `.github/workflows/gh-pages.yml`
|
||||||
|
|
||||||
#### :star: Repository type - Project
|
#### ⭐️ Repository type - Project
|
||||||
|
|
||||||
An example yaml file with Hugo action.
|
An example workflow for Hugo.
|
||||||
|
|
||||||
- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo)
|
- [peaceiris/actions-hugo: GitHub Actions for Hugo](https://github.com/peaceiris/actions-hugo)
|
||||||
|
|
||||||
[](https://github.com/peaceiris/actions-hugo)
|
[](https://github.com/peaceiris/actions-hugo)
|
||||||
|
|
||||||
@@ -86,13 +97,16 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
|
|
||||||
- name: build
|
- name: Setup Hugo
|
||||||
uses: peaceiris/actions-hugo@v0.58.1
|
uses: peaceiris/actions-hugo@v2.2.0
|
||||||
with:
|
with:
|
||||||
args: --gc --minify --cleanDestinationDir
|
hugo-version: '0.58.2'
|
||||||
|
|
||||||
- name: deploy
|
- name: Build
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
run: hugo --gc --minify --cleanDestinationDir
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -101,7 +115,15 @@ jobs:
|
|||||||
|
|
||||||
The above example is for [Project Pages sites]. (`<username>/<project_name>` repository)
|
The above example is for [Project Pages sites]. (`<username>/<project_name>` repository)
|
||||||
|
|
||||||
#### :star: Repository type - User and Organization
|
| Actions log overview | Build step log |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Deploy step log | GitHub Pages log |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
#### ⭐️ Repository type - User and Organization
|
||||||
|
|
||||||
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`.
|
||||||
@@ -118,28 +140,23 @@ 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
|
||||||
[User and Organization Pages sites]: https://help.github.com/en/articles/user-organization-and-project-pages#user-and-organization-pages-sites
|
[User and Organization Pages sites]: https://help.github.com/en/articles/user-organization-and-project-pages#user-and-organization-pages-sites
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
#### :star: Pull action image from Docker Hub
|
#### ⭐️ Pull action image from Docker Hub
|
||||||
|
|
||||||
You can pull a public docker image from Docker Hub.
|
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.0
|
- uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
+ uses: docker://peaceiris/gh-pages:v2.3.0
|
+ uses: docker://peaceiris/gh-pages:v2.3.1
|
||||||
```
|
```
|
||||||
|
|
||||||
- [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)
|
||||||
|
|
||||||
```diff
|
#### ⭐️ `PERSONAL_TOKEN`
|
||||||
- uses: peaceiris/actions-hugo@v0.58.1
|
|
||||||
+ uses: docker://peaceiris/gha-hugo:v0.58.1
|
|
||||||
```
|
|
||||||
|
|
||||||
- [peaceiris/gha-hugo - Docker Hub](https://hub.docker.com/r/peaceiris/gha-hugo)
|
|
||||||
|
|
||||||
#### :star: `PERSONAL_TOKEN`
|
|
||||||
|
|
||||||
[Generate a personal access token (`repo`)](https://github.com/settings/tokens) and add it to Secrets as `PERSONAL_TOKEN`, it works as well as `ACTIONS_DEPLOY_KEY`.
|
[Generate a personal access token (`repo`)](https://github.com/settings/tokens) and add it to Secrets as `PERSONAL_TOKEN`, it works as well as `ACTIONS_DEPLOY_KEY`.
|
||||||
|
|
||||||
@@ -148,16 +165,20 @@ By pulling docker images, you can reduce the overall execution time of your work
|
|||||||
+ PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
|
+ PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### :star: `GITHUB_TOKEN`
|
#### ⭐️ `GITHUB_TOKEN`
|
||||||
|
|
||||||
> **NOTES**: This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. See #9
|
> **NOTES**: Do not use `GITHUB_TOKEN`.
|
||||||
|
>
|
||||||
|
> This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9]
|
||||||
|
|
||||||
|
[Issue #9]: https://github.com/peaceiris/actions-gh-pages/issues/9
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
- ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### :star: Suppressing empty commits
|
#### ⭐️ Suppressing empty commits
|
||||||
|
|
||||||
By default, a commit will always be generated and pushed to the `PUBLISH_BRANCH`, even if nothing changed. If you want to suppress this behavior, set the optional parameter `emptyCommits` to `false`. cf. [Issue #21]
|
By default, a commit will always be generated and pushed to the `PUBLISH_BRANCH`, even if nothing changed. If you want to suppress this behavior, set the optional parameter `emptyCommits` to `false`. cf. [Issue #21]
|
||||||
|
|
||||||
@@ -167,7 +188,7 @@ For example:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -177,6 +198,28 @@ For example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Tips and FAQ
|
||||||
|
|
||||||
|
### How to add `CNAME`
|
||||||
|
|
||||||
|
Most of the Static Site Generators support `CNAME` as a static file.
|
||||||
|
|
||||||
|
- [Use a Custom Domain | Hugo](https://gohugo.io/hosting-and-deployment/hosting-on-github/#use-a-custom-domain)
|
||||||
|
- [Using the Static folder | GatsbyJS](https://www.gatsbyjs.org/docs/static-folder/)
|
||||||
|
|
||||||
|
The same may be said of other files (`.nojekyll`, `BingSiteAuth.xml`, `robots.txt`, etc.). It is better to manage those files by Static Site Generators.
|
||||||
|
|
||||||
|
### Deployment completed but you cannot read
|
||||||
|
|
||||||
|
Does your `PUBLISH_DIR` contain files or directories that name starts with an underscore? (`_modules`, `_sources` and `_next`, etc.)
|
||||||
|
GitHub Pages does not read those by default.
|
||||||
|
Please add `.nojekyll` file to `PUBLISH_DIR`.
|
||||||
|
|
||||||
|
- [Bypassing Jekyll on GitHub Pages - The GitHub Blog](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/)
|
||||||
|
|
||||||
|
> It is now possible to completely bypass Jekyll processing on GitHub Pages by creating a file named `.nojekyll` in the root of your pages repo and pushing it to GitHub. This should only be necessary if your site uses files or directories that start with underscores since Jekyll considers these to be special resources and does not copy them to the final site.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
@@ -217,7 +260,7 @@ jobs:
|
|||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -265,7 +308,7 @@ jobs:
|
|||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -315,7 +358,7 @@ jobs:
|
|||||||
run: touch ./out/.nojekyll
|
run: touch ./out/.nojekyll
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -362,7 +405,7 @@ jobs:
|
|||||||
run: npm run generate
|
run: npm run generate
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
@@ -410,7 +453,7 @@ jobs:
|
|||||||
run: mkdocs build
|
run: mkdocs build
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v2.3.0
|
uses: peaceiris/actions-gh-pages@v2.3.1
|
||||||
env:
|
env:
|
||||||
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
PUBLISH_BRANCH: gh-pages
|
PUBLISH_BRANCH: gh-pages
|
||||||
|
|||||||
@@ -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,7 @@ 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 '*'
|
git rm -r --ignore-unmatch '*'
|
||||||
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 +80,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}"
|
||||||
|
|||||||
BIN
images/default-branch.jpg
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
images/deploy-keys-1.jpg
Normal file
|
After Width: | Height: | Size: 173 KiB |
BIN
images/deploy-keys-2.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
images/log1.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
images/log2.jpg
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
images/log3.jpg
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
images/log4.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
images/secrets-1.jpg
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
images/secrets-2.jpg
Normal file
|
After Width: | Height: | Size: 53 KiB |