xgqfrms / Gatsby-Tutorials-All-In-One

Gatsby-Tutorials-All-In-One
https://gatsby-react-app.xgqfrms.xyz
MIT License
1 stars 0 forks source link

GitHub Actions for GitHub Pages Deploy #4

Open xgqfrms opened 1 year ago

xgqfrms commented 1 year ago

GitHub Actions for GitHub Pages Deploy

GitHub Pages Action 3.4K

https://github.com/peaceiris/actions-gh-pages

https://github.com/marketplace/actions/github-pages-action

  1. 要先手动预构建 public , 才能部署 gh-page
# the next example step will deploy `./public` directory to the remote gh-pages branch.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v3
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

扩展

# the next example step will deploy `./public` directory to the remote gh-pages branch.

runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v3

      - name: Install and Build 🔧 
      # This example project is built using npm and outputs the result to the 'public' folder. 
        run: |
          npm ci
          npm run build

     - name: Deploy
       uses: peaceiris/actions-gh-pages@v3
       with:
         github_token: ${{ secrets.GITHUB_TOKEN }}
         publish_dir: ./public

Deploy to GitHub Pages 3.3K

https://github.com/JamesIves/github-pages-deploy-action

https://github.com/marketplace/actions/deploy-to-github-pages

  1. 要先手动预构建 public , 才能部署 gh-page

构建,发布一条龙

name: Build and Deploy
on: [push]
permissions:
  contents: write
jobs:
  build-and-deploy:
    concurrency: ci-${{ github.ref }} 
    # Recommended if you intend to make multiple deployments in quick succession.
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v3

      - name: Install and Build 🔧 
      # This example project is built using npm and outputs the result to the 'build' folder. 
      # Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
        run: |
          npm ci
          npm run build

      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: build # The folder the action should deploy.

gatsby-gh-pages-action 👎 275

https://github.com/enriikke/gatsby-gh-pages-action

https://github.com/marketplace/actions/gatsby-gh-pages-action

# This GitHub Action will run `gatsby build` at the root of your repository and deploy it to GitHub Pages for you!
name: Gatsby Publish

on:
  push:
    branches:
      - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: enriikke/gatsby-gh-pages-action@v2
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}
xgqfrms commented 1 year ago

GitHub Actions In Action All In One

https://www.cnblogs.com/xgqfrms/p/12818058.html

如何使用 GitHub Actions 发布 Gatsby 静态网站 All In One

https://www.cnblogs.com/xgqfrms/p/16538751.html

create GitHub Actions and publish GitHub Actions All In One

https://www.cnblogs.com/xgqfrms/p/16584689.html

xgqfrms commented 1 year ago

https://github.com/marketplace/actions/gh-pages-for-github-action

https://github.com/marketplace/actions/github-pages-v3

https://github.com/marketplace/actions/gh-pages-deploy

xgqfrms commented 1 year ago

GitHub Actions

https://docs.github.com/cn/actions

https://github.com/xgqfrms/SwiftUI-In-Action

https://github.com/xgqfrms/hello-github-actions

https://github.com/xgqfrms/GitHub-Actions-All-in-One

https://www.cnblogs.com/xgqfrms/p/16584689.html

https://github.com/xgqfrms/GitHub-Actions-All-in-One/blob/master/.github/workflows/dev-ops.yml

# This is a basic workflow to help you get started with Actions

name: 🚀 DevOps 👻 CI/CD

# 控制 action 何时运行
# 在 push 或 pull 请求时触发工作流程事件,但仅针对  master 分支
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# 一个 workflow 运行由可以串行或并行运行的一个或多个 jobs 组成
jobs:
  # 此工作流程仅包含一个名为 "build" 的 job
  build:
    # job 将运行的 runner 类型(执行的系统环境 Linux/ macOS / Windows)
    runs-on: ubuntu-latest

    # 步骤表示将作为 job 一部分执行的一系列 tasks
    steps:
      # 在 $GITHUB_WORKSPACE下检出你的repository,以便你的 job 可以访问它
      - uses: actions/checkout@v2

      # 使用 runners shell 运行单个命令 
      - name: Run a one-line script ✅ 👨🏻‍💻
        run: echo 正在执行单个命令! 

      # 使用 runners shell 运行一组命令
      - name: Run a multi-line script ✅ 👨🏻‍💻
        run: |
          echo 正在执行多个命令的 lint
          echo 正在执行多个命令的 test
          echo 正在执行多个命令的 build
          echo 正在执行多个命令的 deploy
          echo 正在执行多个命令的 npm publish
          echo finished 🎉
xgqfrms commented 1 year ago

https://github.com/marketplace/actions/deploy-to-github-pages

Personal Access Token (PAT)

SSH key

image image
xgqfrms commented 1 year ago

https://www.npmjs.com/package/gh-pages

https://github.com/tschaub/gh-pages