尝试使用 GitHub 操作将 Blazor 发布到 GitHub 页面
trying to publish Blazor to GitHub pages using GitHub Actions
我正在尝试使用 GitHub 操作将 Blazor 发布到 GitHub 页面。
我用了this tutorial and this example, use GitHub Pages Deploy Action.
我的main.yml:
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
- name: Publish with dotnet
run: dotnet publish --configuration Release --output build
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_BRANCH: master
BRANCH: gh-pages-people # The branch the action should deploy to.
FOLDER: build/BlazorGame/dist # The folder the action should deploy.
CLEAN: true
所以,它在我的主控中编译代码,然后应该创建新分支并在那里部署编译代码。
我打电话给我的分支机构 people-publish 并且发布正常:
git switch -c gh-action-temp-deployment-branch
Switched to a new branch 'gh-action-temp-deployment-branch'
git commit -m Deploying to people-publish from master 56b7095f73aeb2fa7850956778934c04d3a7eac6 --quiet
git push --force https://***@github.com/alexan1/BlazorGame.git gh-action-temp-deployment-branch:people-publish
To https://github.com/alexan1/BlazorGame.git
d2a2c28..28c546d gh-action-temp-deployment-branch -> people-publish
Running post deployment cleanup jobs...
rm -rf gh-action-temp-deployment-folder
git checkout --progress --force 56b7095f73aeb2fa7850956778934c04d3a7eac6
Note: switching to '56b7095f73aeb2fa7850956778934c04d3a7eac6'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 56b7095 Create .nojekyll
Completed Deployment ✅
但是 GitHub Pages 选项中没有这个分支,只有 master 和 doc。
所以我决定分支应该以 gh-pages 名称开头。
所以我把它改成 gh-pages-people.
但现在部署失败:
Branch 'master' set up to track remote branch 'master' from 'origin'.
git switch --orphan gh-pages-people
Switched to a new branch 'gh-pages-people'
git reset --hard
git commit --allow-empty -m Initial gh-pages-people commit.
[gh-pages-people (root-commit) bbc1556] Initial gh-pages-people commit.
git push https://***@github.com/alexan1/BlazorGame.git gh-pages-people
remote:
remote: Create a pull request for 'gh-pages-people' on GitHub by visiting:
remote: https://github.com/alexan1/BlazorGame/pull/new/gh-pages-people
remote:
To https://github.com/alexan1/BlazorGame.git
* [new branch] gh-pages-people -> gh-pages-people
git switch master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
git switch master
Already on 'master'
Your branch is up to date with 'origin/master'.
git fetch https://***@github.com/alexan1/BlazorGame.git
From https://github.com/alexan1/BlazorGame
* branch HEAD -> FETCH_HEAD
git worktree add --checkout gh-action-temp-deployment-folder origin/gh-pages-people
fatal: invalid reference: origin/gh-pages-people
The deployment encountered an error. ❌
##[error]The process 'git' failed with exit code 128
Completed Deployment ✅
##[error]Node run failed with exit code 1
Complete job
我又尝试改回分支名称,但总是失败。
已创建新分支,但它是空的。
我做错了什么?
部署正常,但您需要满足两个条件:
Action运行第一次创建分支,部署失败。您需要 运行 第二次操作(新承诺)并将其部署到已创建的分支。由于分支存在,您之后可以执行的所有操作都将毫无问题地部署。
不确定如何解决它,也许在创建分支和部署之间增加一些延迟,但我不需要担心,因为我的问题已解决。
为了能够从分支发布 GitHub 页面,分支名称应该完全是 gh-pages,没有任何修改。
我正在尝试使用 GitHub 操作将 Blazor 发布到 GitHub 页面。
我用了this tutorial and this example, use GitHub Pages Deploy Action.
我的main.yml:
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
- name: Publish with dotnet
run: dotnet publish --configuration Release --output build
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_BRANCH: master
BRANCH: gh-pages-people # The branch the action should deploy to.
FOLDER: build/BlazorGame/dist # The folder the action should deploy.
CLEAN: true
所以,它在我的主控中编译代码,然后应该创建新分支并在那里部署编译代码。
我打电话给我的分支机构 people-publish 并且发布正常:
git switch -c gh-action-temp-deployment-branch
Switched to a new branch 'gh-action-temp-deployment-branch'
git commit -m Deploying to people-publish from master 56b7095f73aeb2fa7850956778934c04d3a7eac6 --quiet
git push --force https://***@github.com/alexan1/BlazorGame.git gh-action-temp-deployment-branch:people-publish
To https://github.com/alexan1/BlazorGame.git
d2a2c28..28c546d gh-action-temp-deployment-branch -> people-publish
Running post deployment cleanup jobs...
rm -rf gh-action-temp-deployment-folder
git checkout --progress --force 56b7095f73aeb2fa7850956778934c04d3a7eac6
Note: switching to '56b7095f73aeb2fa7850956778934c04d3a7eac6'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 56b7095 Create .nojekyll
Completed Deployment ✅
但是 GitHub Pages 选项中没有这个分支,只有 master 和 doc。
所以我决定分支应该以 gh-pages 名称开头。
所以我把它改成 gh-pages-people.
但现在部署失败:
Branch 'master' set up to track remote branch 'master' from 'origin'.
git switch --orphan gh-pages-people
Switched to a new branch 'gh-pages-people'
git reset --hard
git commit --allow-empty -m Initial gh-pages-people commit.
[gh-pages-people (root-commit) bbc1556] Initial gh-pages-people commit.
git push https://***@github.com/alexan1/BlazorGame.git gh-pages-people
remote:
remote: Create a pull request for 'gh-pages-people' on GitHub by visiting:
remote: https://github.com/alexan1/BlazorGame/pull/new/gh-pages-people
remote:
To https://github.com/alexan1/BlazorGame.git
* [new branch] gh-pages-people -> gh-pages-people
git switch master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
git switch master
Already on 'master'
Your branch is up to date with 'origin/master'.
git fetch https://***@github.com/alexan1/BlazorGame.git
From https://github.com/alexan1/BlazorGame
* branch HEAD -> FETCH_HEAD
git worktree add --checkout gh-action-temp-deployment-folder origin/gh-pages-people
fatal: invalid reference: origin/gh-pages-people
The deployment encountered an error. ❌
##[error]The process 'git' failed with exit code 128
Completed Deployment ✅
##[error]Node run failed with exit code 1
Complete job
我又尝试改回分支名称,但总是失败。
已创建新分支,但它是空的。
我做错了什么?
部署正常,但您需要满足两个条件:
Action运行第一次创建分支,部署失败。您需要 运行 第二次操作(新承诺)并将其部署到已创建的分支。由于分支存在,您之后可以执行的所有操作都将毫无问题地部署。 不确定如何解决它,也许在创建分支和部署之间增加一些延迟,但我不需要担心,因为我的问题已解决。
为了能够从分支发布 GitHub 页面,分支名称应该完全是 gh-pages,没有任何修改。