Skip to content

Commit 855ba06

Browse files
authored
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
1 parent 159b07d commit 855ba06

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

.github/workflows/docker-image-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
types: [opened, synchronize]
66
push:
7+
branches:
8+
- master
79

810
jobs:
911
test:

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The above example step will deploy `./public` directory to `gh-pages` branch.
4646
- [⭐️ Suppressing empty commits](#%EF%B8%8F-suppressing-empty-commits)
4747
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
4848
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
49+
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
4950
- [Tips and FAQ](#tips-and-faq)
5051
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
5152
- [⭐️ 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
196197

197198
### ⭐️ `GITHUB_TOKEN`
198199

199-
> **NOTES**: Do not use `GITHUB_TOKEN`.
200+
> ⚠️ **NOTES**: `GITHUB_TOKEN` works only on a **private** repository.
200201
>
201202
> This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9]
202203

@@ -247,6 +248,7 @@ For example:
247248

248249
By default, your files are published to the repository which is running this action.
249250
If you want to publish to another repository on GitHub, set the environment variable `EXTERNAL_REPOSITORY` to `<username>/<external-repository>`.
251+
This option is available from `v2.5.0`.
250252

251253
For example:
252254

@@ -265,6 +267,26 @@ When you use `ACTIONS_DEPLOY_KEY`, set your private key to the repository which
265267

266268
Be careful, `GITHUB_TOKEN` has no permission to access to external repositories.
267269

270+
### ⭐️ Script mode
271+
272+
From `v2.5.0`, we can run this action as a shell script.
273+
There is no Docker build or pull step, so it will start immediately.
274+
275+
- `ACTIONS_DEPLOY_KEY` requires `SCRIPT_MODE: true`
276+
- `*_TOKEN` do not require `SCRIPT_MODE`
277+
278+
```yaml
279+
- name: Deploy
280+
env:
281+
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
282+
PUBLISH_BRANCH: gh-pages
283+
PUBLISH_DIR: ./public
284+
SCRIPT_MODE: true
285+
run: |
286+
wget https://raw.githubusercontent.com/peaceiris/actions-gh-pages/v2.5.0/entrypoint.sh
287+
bash ./entrypoint.sh
288+
```
289+
268290
<div align="right">
269291
<a href="#table-of-contents">Back to TOC ☝️</a>
270292
</div>

entrypoint.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ if [ -n "${ACTIONS_DEPLOY_KEY}" ]; then
2828

2929
print_info "setup with ACTIONS_DEPLOY_KEY"
3030

31-
mkdir /root/.ssh
32-
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts
33-
echo "${ACTIONS_DEPLOY_KEY}" > /root/.ssh/id_rsa
34-
chmod 400 /root/.ssh/id_rsa
31+
if [ -n "${SCRIPT_MODE}" ]; then
32+
print_info "run as SCRIPT_MODE"
33+
SSH_DIR="${HOME}/.ssh"
34+
else
35+
SSH_DIR="/root/.ssh"
36+
fi
37+
mkdir "${SSH_DIR}"
38+
ssh-keyscan -t rsa github.com > "${SSH_DIR}/known_hosts"
39+
echo "${ACTIONS_DEPLOY_KEY}" > "${SSH_DIR}/id_rsa"
40+
chmod 400 "${SSH_DIR}/id_rsa"
3541

3642
remote_repo="[email protected]:${PUBLISH_REPOSITORY}.git"
3743

@@ -44,7 +50,7 @@ elif [ -n "${PERSONAL_TOKEN}" ]; then
4450
elif [ -n "${GITHUB_TOKEN}" ]; then
4551

4652
print_info "setup with GITHUB_TOKEN"
47-
print_error "Do not use GITHUB_TOKEN, See #9"
53+
print_error "GITHUB_TOKEN works only private repo, See #9"
4854

4955
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
5056
print_error "can not use GITHUB_TOKEN to deploy to a external repository"
@@ -70,7 +76,7 @@ fi
7076

7177
remote_branch="${PUBLISH_BRANCH}"
7278

73-
local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)"
79+
local_dir="${HOME}/ghpages_${RANDOM}"
7480
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
7581
cd "${local_dir}"
7682

0 commit comments

Comments
 (0)