如何使用 GitHub Actions 发布 Gatsby 静态网站 All In One
SSG 静态网站生成器
gatsby-gh-pages-action
https://github.com/enriikke/gatsby-gh-pages-action
secrets.ACCESS_TOKEN
https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/settings/secrets/actions/new
https://github.com/settings/tokens/new
name: Gatsby Auto Publish
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: enriikke/gatsby-gh-pages-action@v2
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
CNAME
https://github.com/enriikke/gatsby-gh-pages-action#cname
https://gatsby-react-app.xgqfrms.xyz/
gh-pages
$ yarn add -D gh-pages
https://www.npmjs.com/package/gh-pages
https://github.com/tschaub/gh-pages
gatsby-config.js
module.exports = {
pathPrefix: "/github-repo-name",
}
package.json
{
"scripts": {
"deploy": "gatsby build --prefix-paths && gh-pages -d public"
}
}
demo
/static/CNAME
✅
/CNAME
❌
- 运行
yarn deploy
/npm run deploy
会自动把
/static/CNAME
和public
文件夹一起部署到 gp-pages 分支上
- auto deploy ci
使用
GitHub Actions
自动发布 (❓ 不好使,要手动本地 yarn deploy 才行 ❓)
https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/blob/master/.github/workflows/deploy.yml
https://gatsby-react-app.xgqfrms.xyz/
GitHub & Gatsby
https://github.com/xgqfrms?tab=repositories&q=gatsby&type=&language=&sort=
gatsby-react-app
https://abc.xgqfrms.xyz/gatsby-react-app/
https://abc.xgqfrms.xyz/Gatsby-Tutorials-All-In-One/
GitHub Pages
https://www.youtube.com/watch?v=2MsN8gpT6jY&lc=UggLbBLNhrWRZ3gCoAEC.8MA5ZBZcK-a9M2QCSNoJmy
refs
https://www.cnblogs.com/xgqfrms/p/10720612.html
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!