angular.json
projects > {your-project-name} > architect > build > options > outputPath
如果默认生成静态网页在browser下,记得修改/添加属性
"baseHref": "/browser/",安装angular-cli-ghpages
ng add angular-cli-ghpages.github/workflows下创建工作流
name: Deploy to GitHub Pages
on: push: branches: - master # 或者你要监控的分支名称
jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3
- name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' # 请根据项目需求修改 Node.js 版本
- name: Install dependencies run: npm install
- name: Build project run: npm run build
- name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: folder: dist/my-angular-project/browser # 请根据实际输出路径填写 token: ${{ secrets.TOKEN }}
env: GITHUB_TOKEN: ${{ secrets.TOKEN }}记得在github中生成token用于访问repo,并在action的环境变量中添加。
https://github.com/${your_name}/${your_repo}/settings/secrets/actions
推送到监控的分支
修改github page配置,设置page分支为gh-pages
angular.json
projects > {your-project-name} > architect > build > options > outputPath
If the default static webpage is generated under the browser, remember to modify/add the property
"baseHref": "/browser/",Install angular-cli-ghpages
ng add angular-cli-ghpagesCreate a workflow in .github/workflows
name: Deploy to GitHub Pages
on: push: branches: - master # 或者你要监控的分支名称
jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3
- name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' # 请根据项目需求修改 Node.js 版本
- name: Install dependencies run: npm install
- name: Build project run: npm run build
- name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: folder: dist/my-angular-project/browser # 请根据实际输出路径填写 token: ${{ secrets.TOKEN }}
env: GITHUB_TOKEN: ${{ secrets.TOKEN }}Remember to generate a token on GitHub to access the repo, and add it to the action’s environment variables.
https://github.com/${your_name}/${your_repo}/settings/secrets/actions
Push to the monitored branch
Modify the GitHub Pages configuration, and set the Pages branch to gh-pages
angular.json
projects > {your-project-name} > architect > build > options > outputPath
デフォルトで静的ウェブページがブラウザで生成される場合は、属性を変更/追加してください
"baseHref": "/browser/",angular-cli-ghpages のインストール
ng add angular-cli-ghpages.github/workflowsでワークフローを作成
name: Deploy to GitHub Pages
on: push: branches: - master # 或者你要监控的分支名称
jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3
- name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' # 请根据项目需求修改 Node.js 版本
- name: Install dependencies run: npm install
- name: Build project run: npm run build
- name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: folder: dist/my-angular-project/browser # 请根据实际输出路径填写 token: ${{ secrets.TOKEN }}
env: GITHUB_TOKEN: ${{ secrets.TOKEN }}GitHubでトークンを生成してください(https://github.com/settings/tokens)リポジトリへアクセスするために使用します。また、Actions の環境変数に追加してください。
https://github.com/${your_name}/${your_repo}/settings/secrets/actions
監視対象のブランチへプッシュ
GitHub Pages の設定を変更し、ページ用のブランチを gh-pages に設定します。
部分信息可能已经过时









