Skip to content

Commit

Permalink
release v1.1.0 (#4)
Browse files Browse the repository at this point in the history
* change: use GITHUB_TOKEN instead of ACTIONS_DEPLOY_KEY

* enhance: entrypoint.sh

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

* remove: images/patreon.jpg
  • Loading branch information
peaceiris authored Aug 7, 2019
1 parent 1f78e2b commit 5af287f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
31 changes: 6 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,7 @@ 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.

Expand All @@ -60,18 +43,18 @@ action "is-not-branch-deleted" {
action "build" {
needs = ["is-branch-master", "is-not-branch-deleted"]
uses = "peaceiris/actions-hugo@v0.55.6"
uses = "peaceiris/actions-hugo@v0.56.3"
args = ["--gc", "--minify", "--cleanDestinationDir"]
}
action "deploy" {
needs = "build"
uses = "peaceiris/actions-gh-pages@v1.0.1"
uses = "peaceiris/actions-gh-pages@v1.1.0"
env = {
PUBLISH_DIR = "./public"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
secrets = ["GITHUB_TOKEN"]
}
```

Expand Down Expand Up @@ -115,12 +98,12 @@ action "mkdocs-build" {
action "deploy" {
needs = ["mkdocs-build"]
uses = "peaceiris/actions-gh-pages@v1.0.1"
uses = "peaceiris/actions-gh-pages@v1.1.0"
env = {
PUBLISH_DIR = "./site"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
secrets = ["GITHUB_TOKEN"]
}
```

Expand All @@ -137,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>
26 changes: 13 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Binary file removed images/patreon.jpg
Binary file not shown.

0 comments on commit 5af287f

Please sign in to comment.