Compare commits

...

14 Commits

Author SHA1 Message Date
peaceiris
b6a9b4b75a Merge branch 'master' into force-orphan 2019-10-17 16:38:24 +09:00
peaceiris
69067de181 docs: Remove the link to actions tab
We need to login to access the actions tab.

https://github.com/sdras/awesome-actions/issues/232
2019-10-17 16:36:44 +09:00
peaceiris
a0131c39a3 enhance: forceOrphan condition check 2019-10-17 08:53:02 +09:00
peaceiris
a899cb542b fix: Force push when forceOrphan is true 2019-10-17 07:51:48 +09:00
peaceiris
f83fbff9f3 fix: forceOrphan condition check 2019-10-17 07:46:50 +09:00
peaceiris
7216888f95 feat: Add INPUT_FORCEORPHAN, close #42 2019-10-17 07:41:16 +09:00
peaceiris
7f7794a793 docs: update Hugo workflow example, enhance build step 2019-10-14 22:03:59 +09:00
peaceiris
e60d374041 docs: Enhance node-version 2019-10-08 18:59:10 +09:00
imgbot[bot]
8191f265b1 [ImgBot] Optimize images (#40)
/images/ogp.svg -- 45.84kb -> 45.82kb (0.05%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2019-10-08 14:00:13 +09:00
peaceiris
4eb9565412 docs: update 2019-10-07 03:20:07 +09:00
peaceiris
e5910bfc4f docs: update tag 2019-10-07 00:21:11 +09:00
peaceiris
09158e35aa docs: Fix tag 2019-10-07 00:01:25 +09:00
peaceiris
26405de510 docs: update latest tag 2019-10-07 00:00:09 +09:00
Shohei Ueda
855ba06744 Release: v2.5.0 (#38)
* gha: enhance trigger
* feat: Add SCRIPT_MODE
* docs: Update about GITHUB_TOKEN
* docs: Add new section about Script mode, close #37
2019-10-06 23:53:36 +09:00
5 changed files with 75 additions and 49 deletions

View File

@@ -4,6 +4,8 @@ on:
pull_request: pull_request:
types: [opened, synchronize] types: [opened, synchronize]
push: push:
branches:
- master
jobs: jobs:
test: test:

View File

@@ -1,7 +1,7 @@
[![license](https://img.shields.io/github/license/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE) [![license](https://img.shields.io/github/license/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE)
[![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)
[![GitHub Actions status](https://github.com/peaceiris/actions-gh-pages/workflows/docker%20image%20ci/badge.svg)](https://github.com/peaceiris/actions-gh-pages/actions) ![GitHub Actions status](https://github.com/peaceiris/actions-gh-pages/workflows/docker%20image%20ci/badge.svg)
[![Docker Hub Build Status](https://img.shields.io/docker/cloud/build/peaceiris/gh-pages.svg)](https://hub.docker.com/r/peaceiris/gh-pages) [![Docker Hub Build Status](https://img.shields.io/docker/cloud/build/peaceiris/gh-pages.svg)](https://hub.docker.com/r/peaceiris/gh-pages)
<img width="400" alt="GitHub Actions for deploying to GitHub Pages with Static Site Generators" src="./images/ogp.svg"> <img width="400" alt="GitHub Actions for deploying to GitHub Pages with Static Site Generators" src="./images/ogp.svg">
@@ -17,7 +17,7 @@ This deploy action can be combined simply and freely with [Static Site Generator
```yaml ```yaml
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -46,6 +46,7 @@ The above example step will deploy `./public` directory to `gh-pages` branch.
- [⭐️ 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) - [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository) - [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
- [Tips and FAQ](#tips-and-faq) - [Tips and FAQ](#tips-and-faq)
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release) - [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
- [⭐️ How to add `CNAME`](#%EF%B8%8F-how-to-add-cname) - [⭐️ How to add `CNAME`](#%EF%B8%8F-how-to-add-cname)
@@ -121,15 +122,15 @@ jobs:
# submodules: true # submodules: true
- name: Setup Hugo - name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.1 uses: peaceiris/actions-hugo@v2.2.2
with: with:
hugo-version: '0.58.3' hugo-version: '0.58.3'
- name: Build - name: Build
run: hugo --gc --minify --cleanDestinationDir run: hugo --gc --minify
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -179,8 +180,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.4.0 - uses: peaceiris/actions-gh-pages@v2.5.0
+ uses: docker://peaceiris/gh-pages:v2.4.0 + uses: docker://peaceiris/gh-pages:v2.5.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)
@@ -196,7 +197,7 @@ By pulling docker images, you can reduce the overall execution time of your work
### ⭐️ `GITHUB_TOKEN` ### ⭐️ `GITHUB_TOKEN`
> **NOTES**: Do not use `GITHUB_TOKEN`. > ⚠️ **NOTES**: `GITHUB_TOKEN` works only on a **private** repository.
> >
> This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9] > This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9]
@@ -217,7 +218,7 @@ For example:
```yaml ```yaml
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -234,7 +235,7 @@ For example:
```yaml ```yaml
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -247,16 +248,17 @@ For example:
By default, your files are published to the repository which is running this action. 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>`. If you want to publish to another repository on GitHub, set the environment variable `EXTERNAL_REPOSITORY` to `<username>/<external-repository>`.
This option is available from `v2.5.0`.
For example: For example:
```yaml ```yaml
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.0-rc0 uses: peaceiris/actions-gh-pages@v2.5.0
env: env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }} ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
EXTERNAL_REPOSITORY: username/external-repository EXTERNAL_REPOSITORY: username/external-repository
PUBLISH_BRANCH: master PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public PUBLISH_DIR: ./public
``` ```
@@ -265,6 +267,26 @@ When you use `ACTIONS_DEPLOY_KEY`, set your private key to the repository which
Be careful, `GITHUB_TOKEN` has no permission to access to external repositories. Be careful, `GITHUB_TOKEN` has no permission to access to external repositories.
### ⭐️ Script mode
From `v2.5.0`, we can run this action as a shell script.
There is no Docker build or pull step, so it will start immediately.
- `ACTIONS_DEPLOY_KEY` requires `SCRIPT_MODE: true`
- `*_TOKEN` do not require `SCRIPT_MODE`
```yaml
- name: Deploy
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
SCRIPT_MODE: true
run: |
wget https://raw.githubusercontent.com/peaceiris/actions-gh-pages/v2.5.0/entrypoint.sh
bash ./entrypoint.sh
```
<div align="right"> <div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a> <a href="#table-of-contents">Back to TOC ☝️</a>
</div> </div>
@@ -360,13 +382,13 @@ jobs:
- name: build - name: build
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.16' node-version: '10.x'
- run: | - run: |
npm install npm install
npm run build npm run build
- name: deploy - name: deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -399,7 +421,7 @@ jobs:
- name: setup node - name: setup node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.16' node-version: '10.x'
- name: install - name: install
run: npm install run: npm install
@@ -414,7 +436,7 @@ jobs:
run: npm run build run: npm run build
- name: deploy - name: deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -449,7 +471,7 @@ jobs:
- name: setup node - name: setup node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.16' node-version: '10.x'
- name: install - name: install
run: yarn install run: yarn install
@@ -464,7 +486,7 @@ jobs:
run: touch ./out/.nojekyll run: touch ./out/.nojekyll
- name: deploy - name: deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -499,7 +521,7 @@ jobs:
- name: setup node - name: setup node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.16' node-version: '10.x'
- name: install - name: install
run: npm install run: npm install
@@ -511,7 +533,7 @@ jobs:
run: npm run generate run: npm run generate
- name: deploy - name: deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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
@@ -559,7 +581,7 @@ jobs:
run: mkdocs build run: mkdocs build
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v2.4.0 uses: peaceiris/actions-gh-pages@v2.5.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

View File

@@ -16,3 +16,7 @@ inputs:
description: 'If existing files in the publish branch should be not removed before deploying' description: 'If existing files in the publish branch should be not removed before deploying'
required: false required: false
default: 'false' default: 'false'
forceOrphan:
description: 'Keep only the latest commit on a GitHub Pages branch'
required: false
default: 'false'

View File

@@ -28,10 +28,16 @@ if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
print_info "setup with ACTIONS_DEPLOY_KEY" print_info "setup with ACTIONS_DEPLOY_KEY"
mkdir /root/.ssh if [ -n "${SCRIPT_MODE}" ]; then
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts print_info "run as SCRIPT_MODE"
echo "${ACTIONS_DEPLOY_KEY}" > /root/.ssh/id_rsa SSH_DIR="${HOME}/.ssh"
chmod 400 /root/.ssh/id_rsa else
SSH_DIR="/root/.ssh"
fi
mkdir "${SSH_DIR}"
ssh-keyscan -t rsa github.com > "${SSH_DIR}/known_hosts"
echo "${ACTIONS_DEPLOY_KEY}" > "${SSH_DIR}/id_rsa"
chmod 400 "${SSH_DIR}/id_rsa"
remote_repo="git@github.com:${PUBLISH_REPOSITORY}.git" remote_repo="git@github.com:${PUBLISH_REPOSITORY}.git"
@@ -44,7 +50,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" print_error "GITHUB_TOKEN works only private repo, See #9"
if [ -n "${EXTERNAL_REPOSITORY}" ]; then if [ -n "${EXTERNAL_REPOSITORY}" ]; then
print_error "can not use GITHUB_TOKEN to deploy to a external repository" print_error "can not use GITHUB_TOKEN to deploy to a external repository"
@@ -70,8 +76,14 @@ fi
remote_branch="${PUBLISH_BRANCH}" remote_branch="${PUBLISH_BRANCH}"
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)" local_dir="${HOME}/ghpages_${RANDOM}"
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
if [[ "${INPUT_FORCEORPHAN}" == "true" ]]; then
print_info "force ophan: ${INPUT_FORCEORPHAN}"
cd "${PUBLISH_DIR}"
git init
git checkout --orphan "${remote_branch}"
elif git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
cd "${local_dir}" cd "${local_dir}"
if [[ ${INPUT_KEEPFILES} == "true" ]]; then if [[ ${INPUT_KEEPFILES} == "true" ]]; then
@@ -104,5 +116,10 @@ else
git commit --allow-empty -m "${COMMIT_MESSAGE}" git commit --allow-empty -m "${COMMIT_MESSAGE}"
fi fi
git push origin "${remote_branch}" if [[ ${INPUT_FORCEORPHAN} == "true" ]]; then
git push origin --force "${remote_branch}"
else
git push origin "${remote_branch}"
fi
print_info "${GITHUB_SHA} was successfully deployed" print_info "${GITHUB_SHA} was successfully deployed"

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB