


笔记
另请参见GitHub官方GitHub页面行动。
这是一个github操作,将静态文件部署到github页面。该部署动作可以与静态站点生成器简单合并。 (Hugo,Mkdocs,Gatsby,MDBook,Next,Nuxt等。)
下一个示例步骤将部署到远程gh-pages分支的./public目录。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public对于GitHub动作的新手:请注意, GITHUB_TOKEN不是个人访问令牌。 github动作跑步者会自动创建一个GITHUB_TOKEN秘密,以在您的工作流程中进行身份验证。因此,您可以在没有任何配置的情况下立即开始部署。
支持三个令牌。
| 令牌 | 私人仓库 | 公共仓库 | 协议 | 设置 |
|---|---|---|---|---|
github_token | ✅️ | ✅️ | https | 不必要 |
deploy_key | ✅️ | ✅️ | SSH | 必要的 |
personal_token | ✅️ | ✅️ | https | 必要的 |
注意:实际上, GITHUB_TOKEN可用于部署到github页面,但仍有一些局限性。对于第一个部署,我们需要在“存储库设置”选项卡上选择gh-pages分支或其他分支。参见使用GITHUB_TOKEN第一次部署
所有动作跑步者:Linux(Ubuntu),MacOS和Windows都得到支持。
| 跑步 | github_token | deploy_key | personal_token |
|---|---|---|---|
| Ubuntu-22.04 | ✅️ | ✅️ | ✅️ |
| Ubuntu-20.04 | ✅️ | ✅️ | ✅️ |
| ubuntu-latest | ✅️ | ✅️ | ✅️ |
| macos-latest | ✅️ | ✅️ | ✅️ |
| Windows-Latest | ✅️ | (2) | ✅️ |
✅️github企业服务器受到2.22.6的支持。
请注意,跑步者创建的GITHUB_TOKEN可能本质上没有在GHES上推出/发布特权。您可能需要为目标存储库写入/请求具有写入权限的技术用户。
github_tokendeploy_keypersonal_tokenpublish_branchpublish_dirdestination_direxclude_assetscnameenable_jekyllallow_empty_commitkeep_filesexternal_repositoryforce_orphanGITHUB_TOKEN部署添加您的工作流文件.github/workflows/gh-pages.yml ,然后将其推到远程默认分支。
这是雨果的示例工作流程。
name : GitHub Pages
on :
push :
branches :
- main # Set a branch name to trigger deployment
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
with :
submodules : true # Fetch Hugo themes (true OR recursive)
fetch-depth : 0 # Fetch all history for .GitInfo and .Lastmod
- name : Setup Hugo
uses : peaceiris/actions-hugo@v2
with :
hugo-version : ' 0.110.0 '
- name : Build
run : hugo --minify
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
# If you're changing the branch from main,
# also change the `main` in `refs/heads/main`
# below accordingly.
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public| 动作日志概述 | github页面日志 |
|---|---|
![]() | ![]() |
github_token此选项适用于GITHUB_TOKEN ,而不是个人访问令牌。
github动作跑步者会自动创建一个GITHUB_TOKEN秘密,以在您的工作流程中使用。您可以在工作流程中使用GITHUB_TOKEN来验证。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public有关GITHUB_TOKEN的更多详细信息:自动令牌身份验证-Github文档
deploy_key读取创建SSH部署密钥,创建SSH部署密钥,然后按以下内容设置deploy_key选项。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
deploy_key : ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir : ./publicpersonal_token生成个人访问令牌( repo ),并将其添加到PERSONAL_TOKEN的秘密中,它与ACTIONS_DEPLOY_KEY一样起作用。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
personal_token : ${{ secrets.PERSONAL_TOKEN }}
publish_dir : ./publicpublish_branch设置一个分支名称作为github页面分支。默认值为gh-pages 。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_branch : your-branch # default: gh-pagespublish_dir部署到GitHub页面的源目录。默认值是public 。默认情况下,只有此DIR的内容被推到GHIB gh-pages分支。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./out # default: publicdestination_dir此功能在Beta上。欢迎任何反馈在第324页
出版分支的目的地子目录。默认值为空。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
destination_dir : subdirexclude_assets此功能在Beta上。欢迎任何反馈在第163期
设置文件或目录以排除出版资产。默认值为.github 。值应用逗号分开。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
exclude_assets : ' .github,exclude-file1,exclude-file2 '将exclude_assets设置为空,以将.github目录包括在部署资产中。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
deploy_key : ${{ secrets.ACTIONS_DEPLOY_KEY }} # Recommended for this usage
# personal_token: ${{ secrets.PERSONAL_TOKEN }} # An alternative
# github_token: ${{ secrets.GITHUB_TOKEN }} # This does not work for this usage
exclude_assets : ' ' exclude_assets选项支持GLOG模式。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
exclude_assets : ' .github,exclude-file.txt,exclude-dir/**.txt 'cname要添加CNAME文件,我们可以设置cname选项。另外,将您的CNAME文件放入您的publish_dir中。 (例如public/CNAME )
有关CNAME文件的更多详细信息,请阅读官方文档:为您的github页面管理一个自定义域-Github文档
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
cname : github.comenable_jekyll如果您希望github页面使用静态站点生成器jekyll处理您的站点,请将enable_jekyll设置为true。
默认情况下,此操作向GitHub页面发出信号,表明该站点不应使用Jekyll处理。这是通过在发布分支上添加一个空的.nojekyll文件来完成的。当该文件已经存在时,此操作无济于事。
绕过Jekyll使部署更快,如果您部署以下划线开头的文件或目录,则是必要的,因为Jekyll认为它们是特殊的资源,并且不将其复制到最终站点。您只需要在要部署jekyll驱动的网站并让github页面进行jekyll处理时,将enable_jekyll设置为true。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
enable_jekyll : true有关.nojekyll的更多详细信息:绕过github页面上的jekyll -github博客
allow_empty_commit默认情况下,当没有文件更改时,将不会生成提交。如果要允许一个空提交,请将可选参数allow_empty_commit设置为true 。
例如:
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
allow_empty_commit : truekeep_files默认情况下,将删除发布分支中的现有文件(或仅在destination_dir中)将被删除。如果您希望操作添加新文件,但请将现有文件保持不变,请将可选参数keep_files设置为true 。
请注意,在大多数情况下,使用静态站点生成器的用户不需要此选项。请重新考虑您的项目结构和构建脚本,或在启用此标志之前使用静态站点生成器的内置功能。
例如:
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
keep_files : true使用V3,此选项不支持使用force_orphan选项。下一个主要版本(版本4)将支持这一点。查看问题#455
external_repository默认情况下,您的文件将发布到正在运行此操作的存储库中。如果要在github上发布到另一个存储库,请将环境变量external_repository设置为<username>/<external-repository> 。
例如:
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
deploy_key : ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository : username/external-repository
publish_branch : your-branch # default: gh-pages
publish_dir : ./public您可以使用deploy_key或personal_token 。当您使用deploy_key时,将私钥设置为包括此操作的存储库,并将您的公钥设置为外部存储库。
请注意, GITHUB_TOKEN无权访问外部存储库。请创建一个个人访问令牌,并将其设置为personal_token ,例如personal_token: ${{ secrets.PERSONAL_TOKEN }} 。
用例:
GitHub免费计划帐户不能在私人存储库中使用GitHub页面。要使您的源内容私有并使用GitHub页面部署,您可以使用此选项将网站从私有存储库部署到公共存储库。
peaceiris/homepage :一个私人存储库与external_repository: peaceiris/peaceiris.github.iopeaceiris/peaceiris.github.io :使用github页面的公共存储库force_orphan我们可以设置force_orphan: true选项。这使您只能使用最新的提交制作发布分支。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
force_orphan : true设置自定义git config user.name和git config user.email 。始终使用同一用户创建提交。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
user_name : ' github-actions[bot] '
user_email : ' github-actions[bot]@users.noreply.github.com ' 
设置自定义提交消息。当我们使用消息docs: Update some post时,将使用消息docs: Update some post ${GITHUB_SHA} 。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
commit_message : ${{ github.event.head_commit.message }} 
要设置无触发提交哈希的完整自定义提交消息,请使用full_commit_message选项而不是commit_message选项。
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
full_commit_message : ${{ github.event.head_commit.message }}这是一个示例工作流程。
name : GitHub Pages
on :
push :
branches :
- main
tags :
- ' v*.*.* '
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Some build
- name : Prepare tag
id : prepare_tag
if : startsWith(github.ref, 'refs/tags/')
run : |
echo "DEPLOY_TAG_NAME=deploy-${TAG_NAME}" >> "${GITHUB_OUTPUT}"
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public
tag_name : ${{ steps.prepare_tag.outputs.DEPLOY_TAG_NAME }}
tag_message : ' Deployment ${{ github.ref_name }} '在本地机器上命令。
$ # On a main branch
$ git tag -a " v1.2.3 " -m " Release v1.2.3 "
$ git push origin " v1.2.3 "
$ # After deployment
$ git fetch origin
$ git tag
deploy-v1.2.3 # Tag on the gh-pages branch
v1.2.3 # Tag on the main branch使用以下命令生成部署密钥。
ssh-keygen -t rsa -b 4096 -C " $( git config user.email ) " -f gh-pages -N " "您将获得2个文件:
gh-pages.pub是公钥gh-pages是私钥接下来,转到存储库设置
ACTIONS_DEPLOY_KEY| 添加您的公钥 | 成功 |
|---|---|
![]() | ![]() |
| 添加您的私钥 | 成功 |
|---|---|
![]() | ![]() |
GITHUB_TOKEN部署GITHUB_TOKEN具有第一个部署的局限性,因此我们必须在“存储库设置”选项卡上选择GitHub页面分支。之后,像以下图片一样进行第二部部署。
| 首先部署失败了 | 转到“设置”选项卡 |
|---|---|
![]() | ![]() |
| 选择分支 | 再次部署并成功 |
|---|---|
![]() | ![]() |
如果操作未能按下以下错误推动提交或标记:
/usr/bin/git push origin gh-pages
remote: Write access to repository not granted.
fatal: unable to access 'https://github.com/username/repository.git/': The requested URL returned error: 403
Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"请在工作流/作业中添加写入permissions.contents 。
permissions :
contents : write另外,您可以通过选择读取和写入权限来配置默认的GITHUB_TOKEN权限。
我们建议您将此动作的最新版本用于稳定的CI/CD。观看此存储库(仅发布)以检查此操作的最新版本很有用。
为了进行连续更新,我们可以使用GitHub本机依赖关系。这是机器人的示例配置。配置文件位于.github/dependabot.yml中。
version : 2
updates :
- package-ecosystem : " github-actions "
directory : " / "
schedule :
interval : " daily "
labels :
- " CI/CD "
commit-message :
prefix : ci有关依赖关系的更多详细信息,请参见官方文档:保持依赖关系自动更新 - github文档
对于定期部署,我们可以设置on.schedule工作流触发器。请参阅预定事件|触发工作流的事件-Github文档
对于手动部署,我们可以设置on.workflow_dispatch工作流触发器。请参阅手动事件workflow_dispatch |触发工作流的事件-Github文档
name : GitHub Pages
on :
push :
branches :
- main
schedule :
- cron : " 22 22 * * * "
workflow_dispatch :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
...参见支持:HashREF禁用/损坏与GitHub Actions安全性最佳实践的执行? ·问题#712·Peaceiris/Actions-GH页面
我们的项目仅在创建发行版时才能建立并提供构建资产。这是为了防止用户使用特定分支(如主)执行此操作。例如,如果我们在主要分支机构中维护构建资产,并且用户使用此操作如下,那么包括破坏更改在内的主要版本将破坏用户的CI工作流程。
- uses : peaceiris/actions-gh-pages@main # Bad example!
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public在此项目中,一定的标签(例如V3)保证不包含破坏变化。但是,我们建议使用标签或提交哈希进行工作流的稳定性。
- uses : peaceiris/[email protected] # tag: Better
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public - uses : peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # commit hash of v3.9.3: Best!
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public为了验证发布资产,我们可以使用以下命令。
git clone https://github.com/peaceiris/actions-gh-pages.git
cd ./actions-gh-pages
git checkout v3.9.3
nvm install
nvm use
npm i -g npm
npm ci
npm run build
git diff ./lib/index.js # We will get zero exit codehexo,vuepress,反应静态,网格,创建反应应用等。在推动工作流程之前,请检查输出目录的位置。例如, create-react-app需要将publish_dir设置为./build
前提:依赖项由package.json和package-lock.json管理
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ~/.npm
key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys : |
${{ runner.os }}-node-
- run : npm ci
- run : npm run build
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public盖茨比(Gatsby.js)项目的一个示例
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ~/.npm
key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys : |
${{ runner.os }}-node-
- run : npm ci
- run : npm run format
- run : npm run test
- run : npm run build
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./public使用Create-Next-App的Next.js(React.js)项目的一个示例
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Get yarn cache
id : yarn-cache
run : echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys : |
${{ runner.os }}-yarn-
- run : yarn install --frozen-lockfile
- run : yarn build
- run : yarn export
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./outnuxt.js(vue.js)项目的一个示例
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ~/.npm
key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys : |
${{ runner.os }}-node-
- run : npm ci
- run : npm test
- run : npm run generate
- name : deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./distDocusaurus的示例工作流程。
npx @docusaurus/init@next init website classic对于创建一个新的Docusaurus项目很有用。
# .github/workflows/deploy.yml
name : GitHub Pages
on :
push :
branches :
- main
paths :
- ' .github/workflows/deploy.yml '
- ' website/** '
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
defaults :
run :
working-directory : website
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Get yarn cache
id : yarn-cache
run : echo "YARN_CACHE_DIR=$(yarn cache dir)" >> "${GITHUB_OUTPUT}"
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ${{ steps.yarn-cache.outputs.YARN_CACHE_DIR }}
key : ${{ runner.os }}-website-${{ hashFiles('**/yarn.lock') }}
restore-keys : |
${{ runner.os }}-website-
- run : yarn install --frozen-lockfile
- run : yarn build
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./website/build鹈鹕,mkdocs,sphinx等。
前提:依赖项由requirements.txt管理。
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Python
uses : actions/setup-python@v3
with :
python-version : ' 3.8 '
- name : Upgrade pip
run : |
# install pip=>20.1 to use "pip cache dir"
python3 -m pip install --upgrade pip
- name : Get pip cache dir
id : pip-cache
run : echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name : Cache dependencies
uses : actions/cache@v3
with :
path : ${{ steps.pip-cache.outputs.dir }}
key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys : |
${{ runner.os }}-pip-
- name : Install dependencies
run : python3 -m pip install -r ./requirements.txt
- run : mkdocs build
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./site示例GitHub操作工作流程将Rust-Lang/MDBook网站部署到GitHub页面。
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup mdBook
uses : peaceiris/actions-mdbook@v1
with :
mdbook-version : ' 0.4.8 '
# mdbook-version: 'latest'
- run : mdbook build
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./book提示:您可能想发布鲁特多克斯。并使用MD文档的相对链接,并通过mdbook对其进行检查。然后,根据文档,您可以将./target/doc/放在./book/src dir之前,然后再mdbook build ,然后最终会进入./book/html/和github页面。
Flutter Web项目的示例工作流程。
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Flutter
run : |
git clone https://github.com/flutter/flutter.git --depth 1 -b beta _flutter
echo "${GITHUB_WORKSPACE}/_flutter/bin" >> ${GITHUB_PATH}
- name : Install
run : |
flutter config --enable-web
flutter pub get
- name : Build
run : flutter build web
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./build/web榆树的示例工作流程。
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : ubuntu-22.04
permissions :
contents : write
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- name : Setup Node
uses : actions/setup-node@v3
with :
node-version : ' 14 '
- name : Setup Elm
run : npm install elm --global
- name : Make
run : elm make --optimize src/Main.elm
- name : Move files
run : |
mkdir ./public
mv ./index.html ./public/
# If you have non-minimal setup with some assets and separate html/js files,
# provide --output=<output-file> option for `elm make` and remove this step
- name : Deploy
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./publicJohnsundell/发布的示例工作流程。
name : GitHub Pages
on :
push :
branches :
- main
pull_request :
jobs :
deploy :
runs-on : macos-latest
concurrency :
group : ${{ github.workflow }}-${{ github.ref }}
steps :
- uses : actions/checkout@v3
- uses : actions/cache@v3
with :
path : |
~/Publish_build
.build
key : ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys : |
${{ runner.os }}-spm-
- name : Setup JohnSundell/Publish
run : |
cd ${HOME}
export PUBLISH_VERSION="0.7.0"
git clone https://github.com/JohnSundell/Publish.git
cd ./Publish && git checkout ${PUBLISH_VERSION}
mv ~/Publish_build .build || true
swift build -c release
cp -r .build ~/Publish_build || true
echo "${HOME}/Publish/.build/release" >> ${GITHUB_PATH}
- run : publish-cli generate
- name : Deploy to GitHub Pages
uses : peaceiris/actions-gh-pages@v4
if : github.ref == 'refs/heads/main'
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
publish_dir : ./Output