|
1 |
| -# actions-gh-deploy |
2 |
| -GitHub Actions for deploying to GitHub Pages with Static Site Generators |
| 1 | +[](https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE) |
| 2 | +[](https://github.com/peaceiris/actions-gh-pages/releases/latest) |
| 3 | +[](https://github.com/peaceiris/actions-gh-pages/releases) |
| 4 | + |
| 5 | +<img width="400" alt="GitHub Actions for deploying to GitHub Pages with Static Site Generators" src="./images/ogp.svg"> |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## GitHub Actions for deploying to GitHub Pages |
| 10 | + |
| 11 | +A GitHub Action to deploy your static site to GitHub Pages with [Static Site Generators] (Hugo, MkDocs, Gatsby, GitBook, etc.) |
| 12 | + |
| 13 | +[Static Site Generators]: https://www.staticgen.com/ |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Getting started |
| 18 | + |
| 19 | +### (1) Add deploy Key |
| 20 | + |
| 21 | +1. Generate deploy key `ssh-keygen -t rsa -b 4096 -C "[email protected]" -f gh-pages -N ""` |
| 22 | +2. Go to "Settings > Deploy Keys" of repository. |
| 23 | +3. Add your public key within "Allow write access" option. |
| 24 | +4. Go to "Settings > Secrets" of repository. |
| 25 | +5. Add your private deploy key as `ACTIONS_DEPLOY_KEY` |
| 26 | + |
| 27 | +### (2) Create `main.workflow` |
| 28 | + |
| 29 | +An example with Hugo action. |
| 30 | + |
| 31 | +- [peaceiris/actions-hugo: GitHub Actions for Hugo extended](https://github.com/peaceiris/actions-hugo) |
| 32 | + |
| 33 | +```hcl |
| 34 | +workflow "GitHub Pages" { |
| 35 | + on = "push" |
| 36 | + resolves = ["deploy"] |
| 37 | +} |
| 38 | +
|
| 39 | +action "is-branch-master" { |
| 40 | + uses = "actions/bin/filter@master" |
| 41 | + args = "branch master" |
| 42 | +} |
| 43 | +
|
| 44 | +action "build" { |
| 45 | + needs = "is-branch-master" |
| 46 | + uses = "peaceiris/[email protected]" |
| 47 | + args = ["--gc", "--minify", "--cleanDestinationDir"] |
| 48 | +} |
| 49 | +
|
| 50 | +action "deploy" { |
| 51 | + needs = "build" |
| 52 | + uses = "peaceiris/[email protected]" |
| 53 | + env = { |
| 54 | + PUBLISH_DIR = "./public" |
| 55 | + PUBLISH_BRANCH = "gh-pages" |
| 56 | + } |
| 57 | + secrets = ["ACTIONS_DEPLOY_KEY"] |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +## License |
| 64 | + |
| 65 | +[MIT License - peaceiris/actions-gh-pages] |
| 66 | + |
| 67 | +[MIT License - peaceiris/actions-gh-pages]: https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +## Supprt author |
| 72 | + |
| 73 | +<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a> |
0 commit comments