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
This commit is contained in:
Shohei Ueda 2019-10-06 23:53:36 +09:00 committed by GitHub
parent 159b07d518
commit 855ba06744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 7 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

@ -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)
@ -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]
@ -247,6 +248,7 @@ 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:
@ -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>

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,7 +76,7 @@ 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 git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
cd "${local_dir}" cd "${local_dir}"