-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.git | ||
.github | ||
LICENSE | ||
README.md | ||
images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
workflow "Main workflow" { | ||
on = "push" | ||
resolves = ["docker-build"] | ||
} | ||
|
||
action "docker-build" { | ||
uses = "actions/docker/cli@master" | ||
args = "build -t peaceiris/actions-gh-deploy ." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM alpine:3.9 | ||
|
||
LABEL "com.github.actions.name"="Deploy to GitHub Pages for Static Site Generator" | ||
LABEL "com.github.actions.description"="A GitHub Action to deploy your static site to GitHub Pages with Static Site Generator" | ||
LABEL "com.github.actions.icon"="upload-cloud" | ||
LABEL "com.github.actions.color"="blue" | ||
|
||
LABEL "repository"="https://github.com/peaceiris/actions-gh-pages" | ||
LABEL "homepage"="https://github.com/peaceiris/actions-gh-pages" | ||
LABEL "maintainer"="peaceiris" | ||
|
||
RUN apk add --no-cache \ | ||
git \ | ||
openssh-client | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT [ "/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,73 @@ | ||
# actions-gh-deploy | ||
GitHub Actions for deploying to GitHub Pages with Static Site Generators | ||
[![license](https://img.shields.io/github/license/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE) | ||
[![release](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases/latest) | ||
[![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases) | ||
|
||
<img width="400" alt="GitHub Actions for deploying to GitHub Pages with Static Site Generators" src="./images/ogp.svg"> | ||
|
||
|
||
|
||
## GitHub Actions for deploying to GitHub Pages | ||
|
||
A GitHub Action to deploy your static site to GitHub Pages with [Static Site Generators] (Hugo, MkDocs, Gatsby, GitBook, etc.) | ||
|
||
[Static Site Generators]: https://www.staticgen.com/ | ||
|
||
|
||
|
||
## Getting started | ||
|
||
### (1) Add deploy Key | ||
|
||
1. Generate deploy key `ssh-keygen -t rsa -b 4096 -C "[email protected]" -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. | ||
|
||
- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo) | ||
|
||
```hcl | ||
workflow "GitHub Pages" { | ||
on = "push" | ||
resolves = ["deploy"] | ||
} | ||
action "is-branch-master" { | ||
uses = "actions/bin/filter@master" | ||
args = "branch master" | ||
} | ||
action "build" { | ||
needs = "is-branch-master" | ||
uses = "peaceiris/[email protected]" | ||
args = ["--gc", "--minify", "--cleanDestinationDir"] | ||
} | ||
action "deploy" { | ||
needs = "build" | ||
uses = "peaceiris/[email protected]" | ||
env = { | ||
PUBLISH_DIR = "./public" | ||
PUBLISH_BRANCH = "gh-pages" | ||
} | ||
secrets = ["ACTIONS_DEPLOY_KEY"] | ||
} | ||
``` | ||
|
||
|
||
|
||
## License | ||
|
||
[MIT License - peaceiris/actions-gh-pages] | ||
|
||
[MIT License - peaceiris/actions-gh-pages]: https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE | ||
|
||
|
||
|
||
## Supprt author | ||
|
||
<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
# setup ssh | ||
if [[ -z "${ACTIONS_DEPLOY_KEY}" ]]; then | ||
echo "error: not found ACTIONS_DEPLOY_KEY" | ||
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} | ||
if [[ -z "${PUBLISH_BRANCH}" ]]; then | ||
echo "error: not found PUBLISH_BRANCH" | ||
exit 1 | ||
fi | ||
remote_repo="[email protected]:${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}" | ||
git checkout "${remote_branch}" || git checkout --orphan "${remote_branch}" | ||
git add --all | ||
timestamp=$(date -u) | ||
git commit -m "Automated deployment: ${timestamp} ${GITHUB_SHA}" | ||
git push origin "${remote_branch}" --force |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.