Compare commits

..

5 Commits

Author SHA1 Message Date
Shohei Ueda
5af287f677 release v1.1.0 (#4)
* change: use GITHUB_TOKEN instead of ACTIONS_DEPLOY_KEY

* enhance: entrypoint.sh

* update: readme for v1.1.0 (Fixes #3)

* remove: images/patreon.jpg
2019-08-07 22:43:26 +09:00
peaceiris
1f78e2b780 add: images and is-not-branch-deleted action 2019-06-12 14:14:55 +09:00
peaceiris
a18ce52dfa add: badges to check the latest version of actions 2019-05-27 06:25:57 +09:00
peaceiris
5ff5415c45 update: sample 2019-05-26 22:42:48 +09:00
peaceiris
4ceb783693 release: v1.0.1 2019-05-26 22:41:32 +09:00
5 changed files with 34 additions and 39 deletions

View File

@@ -16,29 +16,15 @@ A GitHub Action to deploy your static site to GitHub Pages with [Static Site Gen
## Getting started
### (1) Add deploy Key
Generate deploy key with the following command.
```sh
ssh-keygen -t rsa -b 4096 -C "your@email.com" -f gh-pages -N ""
# You will get 2 files:
# gh-pages.pub (public key)
# gh-pages (private key)
```
Next, Go to **Repository Settings**
- 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`
### (2) Create `main.workflow`
### Create `.github/main.workflow`
An example with Hugo action.
- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo)
![peaceiris/actions-hugo latest version](https://img.shields.io/github/release/peaceiris/actions-hugo.svg?label=peaceiris%2Factions-hugo)
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```hcl
workflow "GitHub Pages" {
on = "push"
@@ -50,23 +36,32 @@ action "is-branch-master" {
args = "branch master"
}
action "is-not-branch-deleted" {
uses = "actions/bin/filter@master"
args = "not deleted"
}
action "build" {
needs = "is-branch-master"
uses = "peaceiris/actions-hugo@v0.55.6"
needs = ["is-branch-master", "is-not-branch-deleted"]
uses = "peaceiris/actions-hugo@v0.56.3"
args = ["--gc", "--minify", "--cleanDestinationDir"]
}
action "deploy" {
needs = "build"
uses = "peaceiris/actions-gh-pages@v1.0.0"
uses = "peaceiris/actions-gh-pages@v1.1.0"
env = {
PUBLISH_DIR = "./public"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
secrets = ["GITHUB_TOKEN"]
}
```
| Workflow overview | Actions log |
|---|---|
| ![GitHub Actions for deploying to GitHub Pages Workflow overview](./images/workflow-1.jpg) | ![GitHub Actions for deploying to GitHub Pages Actions log](./images/workflow-2.jpg) |
## Examples
@@ -76,6 +71,8 @@ action "deploy" {
- [peaceiris/actions-pipenv: GitHub Actions for pipenv](https://github.com/peaceiris/actions-pipenv)
- [main.workflow - peaceiris/mkdocs-material-boilerplate](https://github.com/peaceiris/mkdocs-material-boilerplate/blob/master/.github/main.workflow)
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```hcl
workflow "MkDocs workflow" {
on = "push"
@@ -101,12 +98,12 @@ action "mkdocs-build" {
action "deploy" {
needs = ["mkdocs-build"]
uses = "peaceiris/actions-gh-pages@v1.0.0"
uses = "peaceiris/actions-gh-pages@v1.1.0"
env = {
PUBLISH_DIR = "./site"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
secrets = ["GITHUB_TOKEN"]
}
```
@@ -123,5 +120,3 @@ action "deploy" {
## About the author
- [peaceiris's homepage](https://peaceiris.com/)
<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a>

View File

@@ -1,31 +1,31 @@
#!/bin/sh
# setup ssh
if [ -z "${ACTIONS_DEPLOY_KEY}" ]; then
echo "error: not found ACTIONS_DEPLOY_KEY"
# check values
if [ -z "${GITHUB_TOKEN}" ]; then
echo "error: not found GITHUB_TOKEN"
exit 1
fi
if [ -z "${PUBLISH_BRANCH}" ]; then
echo "error: not found PUBLISH_BRANCH"
exit 1
fi
mkdir /root/.ssh
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts
echo "${ACTIONS_DEPLOY_KEY}" > /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
# push to gh-pages branch
if [ -z "${PUBLISH_DIR}" ]; then
echo "error: not found PUBLISH_DIR"
exit 1
fi
cd "${PUBLISH_DIR}" || exit 1
if [ -z "${PUBLISH_BRANCH}" ]; then
echo "error: not found PUBLISH_BRANCH"
exit 1
fi
remote_repo="git@github.com:${GITHUB_REPOSITORY}.git"
# initialize git
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_branch="${PUBLISH_BRANCH}"
git init
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote add origin "${remote_repo}"
# push to publishing branch
git checkout "${remote_branch}" || git checkout --orphan "${remote_branch}"
git add --all
timestamp=$(date -u)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

BIN
images/workflow-1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
images/workflow-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB