Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5af287f677 | ||
|
|
1f78e2b780 | ||
|
|
a18ce52dfa | ||
|
|
5ff5415c45 | ||
|
|
4ceb783693 | ||
|
|
95773e0623 | ||
|
|
f2d1faaacf | ||
|
|
9bfcfe68ee | ||
|
|
6009c110fc | ||
|
|
87dceaf2d6 | ||
|
|
3400745573 | ||
|
|
7c2aa28333 |
8
.github/FUNDING.yml
vendored
Normal file
8
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: peaceiris
|
||||||
|
patreon: peaceiris
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
custom: # Replace with a single custom sponsorship URL
|
||||||
79
README.md
79
README.md
@@ -16,20 +16,15 @@ A GitHub Action to deploy your static site to GitHub Pages with [Static Site Gen
|
|||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
### (1) Add deploy Key
|
### Create `.github/main.workflow`
|
||||||
|
|
||||||
1. Generate deploy key `ssh-keygen -t rsa -b 4096 -C "your@email.com" -f gh-pages -N ""`
|
|
||||||
2. Go to "Settings > Deploy Keys" of repository.
|
|
||||||
3. Add your public key within "Allow write access" option.
|
|
||||||
4. Go to "Settings > Secrets" of repository.
|
|
||||||
5. Add your private deploy key as `ACTIONS_DEPLOY_KEY`
|
|
||||||
|
|
||||||
### (2) Create `main.workflow`
|
|
||||||
|
|
||||||
An example with Hugo action.
|
An example with Hugo action.
|
||||||
|
|
||||||
- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo)
|
- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo)
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
workflow "GitHub Pages" {
|
workflow "GitHub Pages" {
|
||||||
on = "push"
|
on = "push"
|
||||||
@@ -41,20 +36,74 @@ action "is-branch-master" {
|
|||||||
args = "branch master"
|
args = "branch master"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action "is-not-branch-deleted" {
|
||||||
|
uses = "actions/bin/filter@master"
|
||||||
|
args = "not deleted"
|
||||||
|
}
|
||||||
|
|
||||||
action "build" {
|
action "build" {
|
||||||
needs = "is-branch-master"
|
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"]
|
args = ["--gc", "--minify", "--cleanDestinationDir"]
|
||||||
}
|
}
|
||||||
|
|
||||||
action "deploy" {
|
action "deploy" {
|
||||||
needs = "build"
|
needs = "build"
|
||||||
uses = "peaceiris/actions-gh-pages@v1.0.0"
|
uses = "peaceiris/actions-gh-pages@v1.1.0"
|
||||||
env = {
|
env = {
|
||||||
PUBLISH_DIR = "./public"
|
PUBLISH_DIR = "./public"
|
||||||
PUBLISH_BRANCH = "gh-pages"
|
PUBLISH_BRANCH = "gh-pages"
|
||||||
}
|
}
|
||||||
secrets = ["ACTIONS_DEPLOY_KEY"]
|
secrets = ["GITHUB_TOKEN"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| Workflow overview | Actions log |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### MkDocs
|
||||||
|
|
||||||
|
- [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)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```hcl
|
||||||
|
workflow "MkDocs workflow" {
|
||||||
|
on = "push"
|
||||||
|
resolves = ["deploy"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "branch-filter" {
|
||||||
|
uses = "actions/bin/filter@master"
|
||||||
|
args = "branch master"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "pipenv-sync" {
|
||||||
|
needs = ["branch-filter"]
|
||||||
|
uses = "peaceiris/actions-pipenv@3.6"
|
||||||
|
args = "sync"
|
||||||
|
}
|
||||||
|
|
||||||
|
action "mkdocs-build" {
|
||||||
|
needs = ["pipenv-sync"]
|
||||||
|
uses = "peaceiris/actions-pipenv@3.6"
|
||||||
|
args = ["run", "mkdocs", "build", "--config-file", "./mkdocs-sample.yml"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "deploy" {
|
||||||
|
needs = ["mkdocs-build"]
|
||||||
|
uses = "peaceiris/actions-gh-pages@v1.1.0"
|
||||||
|
env = {
|
||||||
|
PUBLISH_DIR = "./site"
|
||||||
|
PUBLISH_BRANCH = "gh-pages"
|
||||||
|
}
|
||||||
|
secrets = ["GITHUB_TOKEN"]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -68,6 +117,6 @@ action "deploy" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Supprt author
|
## About the author
|
||||||
|
|
||||||
<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a>
|
- [peaceiris's homepage](https://peaceiris.com/)
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# setup ssh
|
# check values
|
||||||
if [[ -z "${ACTIONS_DEPLOY_KEY}" ]]; then
|
if [ -z "${GITHUB_TOKEN}" ]; then
|
||||||
echo "error: not found ACTIONS_DEPLOY_KEY"
|
echo "error: not found GITHUB_TOKEN"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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_BRANCH}" ]; then
|
||||||
if [[ -z "${PUBLISH_DIR}" ]]; then
|
|
||||||
echo "error: not found PUBLISH_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
cd ${PUBLISH_DIR}
|
|
||||||
if [[ -z "${PUBLISH_BRANCH}" ]]; then
|
|
||||||
echo "error: not found PUBLISH_BRANCH"
|
echo "error: not found PUBLISH_BRANCH"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
remote_repo="git@github.com:${GITHUB_REPOSITORY}.git"
|
|
||||||
|
if [ -z "${PUBLISH_DIR}" ]; then
|
||||||
|
echo "error: not found PUBLISH_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cd "${PUBLISH_DIR}" || exit 1
|
||||||
|
|
||||||
|
# initialize git
|
||||||
|
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||||
remote_branch="${PUBLISH_BRANCH}"
|
remote_branch="${PUBLISH_BRANCH}"
|
||||||
git init
|
git init
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
git remote add origin "${remote_repo}"
|
git remote add origin "${remote_repo}"
|
||||||
|
|
||||||
|
# push to publishing branch
|
||||||
git checkout "${remote_branch}" || git checkout --orphan "${remote_branch}"
|
git checkout "${remote_branch}" || git checkout --orphan "${remote_branch}"
|
||||||
git add --all
|
git add --all
|
||||||
timestamp=$(date -u)
|
timestamp=$(date -u)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB |
BIN
images/workflow-1.jpg
Normal file
BIN
images/workflow-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
images/workflow-2.jpg
Normal file
BIN
images/workflow-2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user