由于环保规则,分支“master”不允许部署到github-pages

Tom*_*ica 1 github-actions

我将要从主分支部署的操作工作流程复制到gh-pages官方 github 启动工作流程:

https://github.com/actions/starter-workflows/blob/main/pages/static.yml

这是我使用的版本:

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: [$default-branch]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Single deploy job since we're just deploying
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v2
        with:
          # Upload entire repository
          path: './web/root'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v2
Run Code Online (Sandbox Code Playgroud)

唯一的变化是更改../web/root. 我在工作流程中收到此错误:


Branch "master" is not allowed to deploy to github-pages due to environment protection rules.
Run Code Online (Sandbox Code Playgroud)

我有一个gh-pages分行和一个master分行。我需要进行哪些更改才能允许在 中的子文件夹中发布页面master

Sas*_*cha 10

听起来您的环境已经设置了一些保护。您可以尝试以下操作:

  1. 转到您的存储库设置
  2. 单击环境
  3. 选择您的环境github-pages
  4. “部署分支”旁边,从下拉列表中选择“选定的分支” 。
  5. 单击添加部署分支规则
  6. 输入模式大师

这应该允许从master分支部署到您的github-pages环境。