mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 12:41:20 +08:00
feat: add es6.md
cheatsheet. b258494776
This commit is contained in:
@ -34,7 +34,7 @@
|
||||
document.documentElement.setAttribute('data-color-mode', mode);
|
||||
localStorage.setItem(LOCAL_NANE, mode);
|
||||
}
|
||||
</script><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap max-container"><header class="wrap-header h1wrap"><h1 id="github-actions-备忘清单"><svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 107 107">
|
||||
</script><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap h1body-exist max-container"><header class="wrap-header h1wrap"><h1 id="github-actions-备忘清单"><svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 107 107">
|
||||
<g fill="none" fill-rule="evenodd" transform="translate(2.982 2.982)">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M19.7678571,0 C30.6853432,0 39.5357143,8.85037111 39.5357143,19.7678571 C39.5357143,30.6853432 30.6853432,39.5357143 19.7678571,39.5357143 C8.85037111,39.5357143 0,30.6853432 0,19.7678571 C0,8.85037111 8.85037111,0 19.7678571,0 L19.7678571,0 Z M48.3214286,39.5357143 C55.5997526,39.5357143 61.5,45.4359617 61.5,52.7142857 C61.5,59.9926097 55.5997526,65.8928571 48.3214286,65.8928571 C41.0431045,65.8928571 35.1428571,59.9926097 35.1428571,52.7142857 C35.1428571,45.4359617 41.0431045,39.5357143 48.3214286,39.5357143 Z M48.3214286,74.6785714 C55.5997526,74.6785714 61.5,80.5788188 61.5,87.8571429 C61.5,95.1354669 55.5997526,101.035714 48.3214286,101.035714 C41.0431045,101.035714 35.1428571,95.1354669 35.1428571,87.8571429 C35.1428571,80.5788188 41.0431045,74.6785714 48.3214286,74.6785714 Z"></path>
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M87.8571429,74.6785714 C95.1354669,74.6785714 101.035714,80.5788188 101.035714,87.8571429 C101.035714,95.1354669 95.1354669,101.035714 87.8571429,101.035714 C80.5788188,101.035714 74.6785714,95.1354669 74.6785714,87.8571429 C74.6785714,80.5788188 80.5788188,74.6785714 87.8571429,74.6785714 Z"></path>
|
||||
@ -51,8 +51,8 @@
|
||||
<p>本备忘单总结了 <a href="https://github.com/actions">Github Actions</a> 常用的配置说明,以供快速参考。</p>
|
||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" href="#配置文件">配置文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定触发">指定触发</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务">多项任务</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务依赖关系">多项任务依赖关系</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务传递参数">多项任务传递参数</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定每项任务的虚拟机环境">指定每项任务的虚拟机环境</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定每项任务的步骤">指定每项任务的步骤</a><a aria-hidden="true" class="leve3 tocs-link" href="#环境变量">环境变量</a><a aria-hidden="true" class="leve4 tocs-link" href="#自定义环境变量">自定义环境变量</a><a aria-hidden="true" class="leve3 tocs-link" href="#表达式">表达式</a><a aria-hidden="true" class="leve4 tocs-link" href="#操作符">操作符</a><a aria-hidden="true" class="leve3 tocs-link" href="#github-上下文">Github 上下文</a><a aria-hidden="true" class="leve3 tocs-link" href="#默认环境变量">默认环境变量</a><a aria-hidden="true" class="leve3 tocs-link" href="#直接常量">直接常量</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-contains">函数 contains</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-startswith">函数 startsWith</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-format">函数 format</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-join">函数 join</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-tojson">函数 toJSON</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数">函数</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-success">函数 success()</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-failure">函数 failure()</a><a aria-hidden="true" class="leve2 tocs-link" href="#常用实例">常用实例</a><a aria-hidden="true" class="leve3 tocs-link" href="#获取版本信息">获取版本信息</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交到-gh-pages-分支">提交到 gh-pages 分支</a><a aria-hidden="true" class="leve3 tocs-link" href="#修改-packagejson">修改 package.json</a><a aria-hidden="true" class="leve3 tocs-link" href="#克隆带有-submodule-的仓库">克隆带有 Submodule 的仓库</a><a aria-hidden="true" class="leve3 tocs-link" href="#步骤依赖作业">步骤依赖作业</a><a aria-hidden="true" class="leve3 tocs-link" href="#同步-gitee">同步 Gitee</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-npm-包">提交 NPM 包</a><a aria-hidden="true" class="leve3 tocs-link" href="#步骤作业文件共享">步骤作业文件共享</a><a aria-hidden="true" class="leve3 tocs-link" href="#nodejs">Node.js</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-docker-镜像">提交 docker 镜像</a><a aria-hidden="true" class="leve3 tocs-link" href="#创建一个-tag">创建一个 tag</a><a aria-hidden="true" class="leve3 tocs-link" href="#生成-git-提交日志">生成 git 提交日志</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交到-github-docker-镜像仓库">提交到 GitHub docker 镜像仓库</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-commit-到-master-分支">提交 commit 到 master 分支</a><a aria-hidden="true" class="leve3 tocs-link" href="#作业之间共享数据">作业之间共享数据</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定运行命令的工作目录">指定运行命令的工作目录</a><a aria-hidden="true" class="leve4 tocs-link" href="#defaultsrun">defaults.run</a><a aria-hidden="true" class="leve3 tocs-link" href="#jobsjob_idstepsshell">jobs.<job_id>.steps[*].shell</a><a aria-hidden="true" class="leve3 tocs-link" href="#一些-actions-推荐">一些 actions 推荐</a><a aria-hidden="true" class="leve2 tocs-link" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap"><div class="wrap-header h3wrap"><h3 id="介绍"><a aria-hidden="true" tabindex="-1" href="#介绍"><span class="icon icon-link"></span></a>介绍</h3><div class="wrap-body">
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" href="#介绍">介绍</a><a aria-hidden="true" class="leve3 tocs-link" href="#配置文件">配置文件</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定触发">指定触发</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务">多项任务</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务依赖关系">多项任务依赖关系</a><a aria-hidden="true" class="leve3 tocs-link" href="#多项任务传递参数">多项任务传递参数</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定每项任务的虚拟机环境">指定每项任务的虚拟机环境</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定每项任务的步骤">指定每项任务的步骤</a><a aria-hidden="true" class="leve3 tocs-link" href="#环境变量">环境变量</a><a aria-hidden="true" class="leve4 tocs-link" href="#自定义环境变量">自定义环境变量</a><a aria-hidden="true" class="leve3 tocs-link" href="#表达式">表达式</a><a aria-hidden="true" class="leve4 tocs-link" href="#操作符">操作符</a><a aria-hidden="true" class="leve3 tocs-link" href="#github-上下文">Github 上下文</a><a aria-hidden="true" class="leve3 tocs-link" href="#默认环境变量">默认环境变量</a><a aria-hidden="true" class="leve3 tocs-link" href="#直接常量">直接常量</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-contains">函数 contains</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-startswith">函数 startsWith</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-format">函数 format</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-join">函数 join</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-tojson">函数 toJSON</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数">函数</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-success">函数 success()</a><a aria-hidden="true" class="leve3 tocs-link" href="#函数-failure">函数 failure()</a><a aria-hidden="true" class="leve2 tocs-link" href="#常用实例">常用实例</a><a aria-hidden="true" class="leve3 tocs-link" href="#获取版本信息">获取版本信息</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交到-gh-pages-分支">提交到 gh-pages 分支</a><a aria-hidden="true" class="leve3 tocs-link" href="#修改-packagejson">修改 package.json</a><a aria-hidden="true" class="leve3 tocs-link" href="#克隆带有-submodule-的仓库">克隆带有 Submodule 的仓库</a><a aria-hidden="true" class="leve3 tocs-link" href="#步骤依赖作业">步骤依赖作业</a><a aria-hidden="true" class="leve3 tocs-link" href="#同步-gitee">同步 Gitee</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-npm-包">提交 NPM 包</a><a aria-hidden="true" class="leve3 tocs-link" href="#步骤作业文件共享">步骤作业文件共享</a><a aria-hidden="true" class="leve3 tocs-link" href="#nodejs">Node.js</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-docker-镜像">提交 docker 镜像</a><a aria-hidden="true" class="leve3 tocs-link" href="#创建一个-tag">创建一个 tag</a><a aria-hidden="true" class="leve3 tocs-link" href="#生成-git-提交日志">生成 git 提交日志</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交到-github-docker-镜像仓库">提交到 GitHub docker 镜像仓库</a><a aria-hidden="true" class="leve3 tocs-link" href="#提交-commit-到-master-分支">提交 commit 到 master 分支</a><a aria-hidden="true" class="leve3 tocs-link" href="#作业之间共享数据">作业之间共享数据</a><a aria-hidden="true" class="leve3 tocs-link" href="#指定运行命令的工作目录">指定运行命令的工作目录</a><a aria-hidden="true" class="leve4 tocs-link" href="#defaultsrun">defaults.run</a><a aria-hidden="true" class="leve3 tocs-link" href="#jobsjob_idstepsshell">jobs.<job_id>.steps[*].shell</a><a aria-hidden="true" class="leve3 tocs-link" href="#一些-actions-推荐">一些 actions 推荐</a><a aria-hidden="true" class="leve2 tocs-link" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="介绍"><a aria-hidden="true" tabindex="-1" href="#介绍"><span class="icon icon-link"></span></a>介绍</h3><div class="wrap-body">
|
||||
<p>GitHub <a href="https://github.com/actions">Actions</a> 的仓库中自动化、自定义和执行软件开发工作流程,有四个基本的概念,如下:</p>
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
<li>根据配置事件自动运行配置文件</li>
|
||||
</ul>
|
||||
<!--rehype:className=style-round-->
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="配置文件"><a aria-hidden="true" tabindex="-1" href="#配置文件"><span class="icon icon-link"></span></a>配置文件</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="配置文件"><a aria-hidden="true" tabindex="-1" href="#配置文件"><span class="icon icon-link"></span></a>配置文件</h3><div class="wrap-body">
|
||||
<pre class="language-yaml"><code class="language-yaml code-highlight"><span class="code-line"><span class="token key atrule">name</span><span class="token punctuation">:</span> GitHub Actions Demo
|
||||
</span><span class="code-line"><span class="token key atrule">on</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">push</span><span class="token punctuation">:</span>
|
||||
@ -112,7 +112,7 @@
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm run build
|
||||
</span></code></pre>
|
||||
<p>存放到 <code>.github/workflows</code> 目录中,命名为 <code>ci.yml</code>,当 <code>push</code> 代码到仓库 <code>main</code> 分支中,该配置自动运行配置。</p>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="指定触发"><a aria-hidden="true" tabindex="-1" href="#指定触发"><span class="icon icon-link"></span></a>指定触发</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="指定触发"><a aria-hidden="true" tabindex="-1" href="#指定触发"><span class="icon icon-link"></span></a>指定触发</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<p><code>push</code> 事件触发 <code>workflow</code></p>
|
||||
<pre class="language-yaml"><code class="language-yaml code-highlight"><span class="code-line"><span class="token key atrule">on</span><span class="token punctuation">:</span> push
|
||||
@ -144,7 +144,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">release</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">types</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>published<span class="token punctuation">]</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="多项任务"><a aria-hidden="true" tabindex="-1" href="#多项任务"><span class="icon icon-link"></span></a>多项任务</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="多项任务"><a aria-hidden="true" tabindex="-1" href="#多项任务"><span class="icon icon-link"></span></a>多项任务</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">my_first_job</span><span class="token punctuation">:</span> <span class="token comment"># 第一个任务</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">name</span><span class="token punctuation">:</span> My first job
|
||||
@ -153,7 +153,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">name</span><span class="token punctuation">:</span> My second job
|
||||
</span></code></pre>
|
||||
<p>通过 jobs <code>(jobs.<job_id>.name)</code>字段,配置一项或多项需要执行的任务</p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="多项任务依赖关系"><a aria-hidden="true" tabindex="-1" href="#多项任务依赖关系"><span class="icon icon-link"></span></a>多项任务依赖关系</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="多项任务依赖关系"><a aria-hidden="true" tabindex="-1" href="#多项任务依赖关系"><span class="icon icon-link"></span></a>多项任务依赖关系</h3><div class="wrap-body">
|
||||
<p>通过 needs <code>(jobs.<job_id>.needs)</code>字段,指定当前任务的依赖关系</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">job1</span><span class="token punctuation">:</span>
|
||||
@ -163,7 +163,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">needs</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>job1<span class="token punctuation">,</span> job2<span class="token punctuation">]</span>
|
||||
</span></code></pre>
|
||||
<p>上面配置中,<code>job1</code> 必须先于 <code>job2</code> 完成,而 <code>job3</code> 等待 <code>job1</code> 和 <code>job2</code> 的完成才能运行。因此,这个 <code>workflow</code> 的运行顺序依次为:<code>job1</code>、<code>job2</code>、<code>job3</code></p>
|
||||
</div></div></div><div class="wrap col-span-2"><div class="wrap-header h3wrap"><h3 id="多项任务传递参数"><a aria-hidden="true" tabindex="-1" href="#多项任务传递参数"><span class="icon icon-link"></span></a>多项任务传递参数</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="多项任务传递参数"><a aria-hidden="true" tabindex="-1" href="#多项任务传递参数"><span class="icon icon-link"></span></a>多项任务传递参数</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">job1</span><span class="token punctuation">:</span>
|
||||
@ -183,7 +183,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">steps</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> echo $<span class="token punctuation">{</span><span class="token punctuation">{</span>needs.job1.outputs.output1<span class="token punctuation">}</span><span class="token punctuation">}</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span>needs.job1.outputs.output2<span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="指定每项任务的虚拟机环境"><a aria-hidden="true" tabindex="-1" href="#指定每项任务的虚拟机环境"><span class="icon icon-link"></span></a>指定每项任务的虚拟机环境</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="指定每项任务的虚拟机环境"><a aria-hidden="true" tabindex="-1" href="#指定每项任务的虚拟机环境"><span class="icon icon-link"></span></a>指定每项任务的虚拟机环境</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">runs-on</span><span class="token punctuation">:</span> ubuntu<span class="token punctuation">-</span>latest
|
||||
</span></code></pre>
|
||||
<p>指定运行所需要的虚拟机环境,⚠️ 它是必填字段</p>
|
||||
@ -200,7 +200,7 @@
|
||||
</ul>
|
||||
<!--rehype:className=style-arrow-->
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/using-workflows/workflow-syntax-for-github-actions#%E9%80%89%E6%8B%A9-github-%E6%89%98%E7%AE%A1%E7%9A%84%E8%BF%90%E8%A1%8C%E5%99%A8">选择 GitHub 托管的运行器</a></p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="指定每项任务的步骤"><a aria-hidden="true" tabindex="-1" href="#指定每项任务的步骤"><span class="icon icon-link"></span></a>指定每项任务的步骤</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="指定每项任务的步骤"><a aria-hidden="true" tabindex="-1" href="#指定每项任务的步骤"><span class="icon icon-link"></span></a>指定每项任务的步骤</h3><div class="wrap-body">
|
||||
<p>每个步骤都可以指定以下三个字段</p>
|
||||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">jobs.<span class="token operator"><</span>job_id<span class="token operator">></span>.steps.name <span class="token comment"># 步骤名称</span>
|
||||
</span><span class="code-line"><span class="token comment"># 该步骤运行的命令或者 action</span>
|
||||
@ -221,7 +221,7 @@
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm install
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm run build
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="环境变量"><a aria-hidden="true" tabindex="-1" href="#环境变量"><span class="icon icon-link"></span></a>环境变量</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="环境变量"><a aria-hidden="true" tabindex="-1" href="#环境变量"><span class="icon icon-link"></span></a>环境变量</h3><div class="wrap-body">
|
||||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">jobs.<span class="token operator"><</span>job_id<span class="token operator">></span>.environment
|
||||
</span></code></pre>
|
||||
<p>使用单一环境名称的示例</p>
|
||||
@ -232,14 +232,14 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">name</span><span class="token punctuation">:</span> production_environment
|
||||
</span><span class="code-line"> <span class="token key atrule">url</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//github.com
|
||||
</span></code></pre>
|
||||
</div></div><div class="h3wrap-body"><div class="wrap"><div class="wrap-header h4wrap"><h4 id="自定义环境变量"><a aria-hidden="true" tabindex="-1" href="#自定义环境变量"><span class="icon icon-link"></span></a>自定义环境变量</h4><div class="wrap-body">
|
||||
</div></div><div class="h3wrap-body"><div class="wrap h4body-not-exist"><div class="wrap-header h4wrap"><h4 id="自定义环境变量"><a aria-hidden="true" tabindex="-1" href="#自定义环境变量"><span class="icon icon-link"></span></a>自定义环境变量</h4><div class="wrap-body">
|
||||
<p><code>GitHub</code> 会保留 <code>GITHUB_</code> 环境变量前缀供 <code>GitHub</code> 内部使用。设置有 <code>GITHUB_</code> 前缀的环境变量或密码将导致错误。</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> 测试 nodejs 获取环境变量
|
||||
</span><span class="code-line"> <span class="token key atrule">env</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">API_TOKEN</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.API_TOKEN <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
<p>在 <code>https://github.com/<用户名>/<项目名称>/settings/secrets</code> 中添加 <code>secrets</code> <code>API_TOKEN</code>,在工作流中设置环境变量 <a href="https://github.com/jaywcjlove/github-actions/blob/799b232fca3d9df0272eaa12610f9ebfca51b288/.github/workflows/ci.yml#L46"><code>API_TOKEN</code></a></p>
|
||||
</div></div></div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="表达式"><a aria-hidden="true" tabindex="-1" href="#表达式"><span class="icon icon-link"></span></a>表达式</h3><div class="wrap-body">
|
||||
</div></div></div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="表达式"><a aria-hidden="true" tabindex="-1" href="#表达式"><span class="icon icon-link"></span></a>表达式</h3><div class="wrap-body">
|
||||
<p>在 <code>if</code> 条件下使用表达式时,可以省略表达式语法 (<code>${{ }}</code>),因为 GitHub 会自动将 <code>if</code> 条件作为表达式求值</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">steps</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">uses</span><span class="token punctuation">:</span> actions/hello<span class="token punctuation">-</span>world<span class="token punctuation">-</span>action@v1.1
|
||||
@ -250,7 +250,7 @@
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">env</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">MY_ENV_VAR</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> <expression<span class="token punctuation">></span> <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div><div class="h3wrap-body"><div class="wrap"><div class="wrap-header h4wrap"><h4 id="操作符"><a aria-hidden="true" tabindex="-1" href="#操作符"><span class="icon icon-link"></span></a>操作符</h4><div class="wrap-body">
|
||||
</div></div><div class="h3wrap-body"><div class="wrap h4body-not-exist"><div class="wrap-header h4wrap"><h4 id="操作符"><a aria-hidden="true" tabindex="-1" href="#操作符"><span class="icon icon-link"></span></a>操作符</h4><div class="wrap-body">
|
||||
<ul class="cols-2 style-none">
|
||||
<li><code>( )</code> <em>(逻辑分组)</em></li>
|
||||
<li><code>[ ]</code> <em>(指数)</em></li>
|
||||
@ -266,7 +266,7 @@
|
||||
<li><code>||</code> <em>(或者)</em></li>
|
||||
</ul>
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
</div></div></div></div></div><div class="wrap col-span-2"><div class="wrap-header h3wrap"><h3 id="github-上下文"><a aria-hidden="true" tabindex="-1" href="#github-上下文"><span class="icon icon-link"></span></a>Github 上下文</h3><div class="wrap-body">
|
||||
</div></div></div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="github-上下文"><a aria-hidden="true" tabindex="-1" href="#github-上下文"><span class="icon icon-link"></span></a>Github 上下文</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
|
||||
@ -371,7 +371,7 @@
|
||||
<table class="style-list-arrow"><thead><tr><th>属性名称</th><th>类型</th><th>描述</th></tr></thead><tbody><tr><td><code>github</code> <em>(object)</em></td><td>工作流程中任何作业或步骤期间可用的顶层上下文。</td><td></td></tr><tr><td><code>github.event</code> <em>(object)</em></td><td>完整事件 web 挂钩有效负载。 更多信息请参阅“触发工作流程的事件”。</td><td></td></tr><tr><td><code>github.event_path</code> <em>(string)</em></td><td>运行器上完整事件 web 挂钩有效负载的路径。</td><td></td></tr><tr><td><code>github.workflow</code> <em>(string)</em></td><td>工作流程的名称。 如果工作流程文件未指定 name,此属性的值将是仓库中工作流程文件的完整路径。</td><td></td></tr><tr><td><code>github.job</code> <em>(string)</em></td><td>当前作业的 job_id。</td><td></td></tr><tr><td><code>github.run_id</code> <em>(string)</em></td><td>仓库中每个运行的唯一编号。 如果您重新执行工作流程运行,此编号不变。</td><td></td></tr><tr><td><code>github.run_number</code> <em>(string)</em></td><td>仓库中特定工作流程每个运行的唯一编号。 此编号从 1(对应于工作流程的第一个运行)开始,然后随着每个新的运行而递增。 如果您重新执行工作流程运行,此编号不变。</td><td></td></tr><tr><td><code>github.actor</code> <em>(string)</em></td><td>发起工作流程运行的用户的登录名。</td><td></td></tr><tr><td><code>github.repository</code> <em>(string)</em></td><td>所有者和仓库名称。 例如 Codertocat/Hello-World。</td><td></td></tr><tr><td><code>github.repository_owner</code> <em>(string)</em></td><td>仓库所有者的名称。 例如 Codertocat。</td><td></td></tr><tr><td><code>github.event_name</code> <em>(string)</em></td><td>触发工作流程运行的事件的名称。</td><td></td></tr><tr><td><code>github.sha</code> <em>(string)</em></td><td>触发工作流程的提交 SHA。</td><td></td></tr><tr><td><code>github.ref</code> <em>(string)</em></td><td>触发工作流程的分支或标记参考。</td><td></td></tr><tr><td><code>github.head_ref</code> <em>(string)</em></td><td>工作流程运行中拉取请求的 head_ref 或来源分支。 此属性仅在触发工作流程运行的事件为 pull_request 时才可用。</td><td></td></tr><tr><td><code>github.base_ref</code> <em>(string)</em></td><td>工作流程运行中拉取请求的 base_ref 或目标分支。 此属性仅在触发工作流程运行的事件为 pull_request 时才可用。</td><td></td></tr><tr><td><code>github.token</code> <em>(string)</em></td><td>代表仓库上安装的 GitHub 应用程序进行身份验证的令牌。 这在功能上等同于 GITHUB_TOKEN 密码。 更多信息请参阅“使用 GITHUB_TOKEN 验证身份”。</td><td></td></tr><tr><td><code>github.workspace</code> <em>(string)</em></td><td>使用 checkout 操作时步骤的默认工作目录和仓库的默认位置。</td><td></td></tr><tr><td><code>github.action</code> <em>(string)</em></td><td>正在运行的操作的名称。 在当前步骤运行脚本时,GitHub 删除特殊字符或使用名称 run。 如果在同一作业中多次使用相同的操作,则名称将包括带有序列号的后缀。 例如,运行的第一个脚本名称为 run1,则第二个脚本将命名为 run2。 同样,actions/checkout 第二次调用时将变成 actionscheckout2。</td><td></td></tr></tbody></table>
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
<p><a href="https://help.github.com/cn/actions/reference/context-and-expression-syntax-for-github-actions">Github 上下文</a>是访问有关工作流运行、运行器环境、作业和步骤的信息的一种方式</p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="默认环境变量"><a aria-hidden="true" tabindex="-1" href="#默认环境变量"><span class="icon icon-link"></span></a>默认环境变量</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="默认环境变量"><a aria-hidden="true" tabindex="-1" href="#默认环境变量"><span class="icon icon-link"></span></a>默认环境变量</h3><div class="wrap-body">
|
||||
|
||||
|
||||
|
||||
@ -456,7 +456,7 @@
|
||||
<table class="style-list-arrow"><thead><tr><th>环境变量</th><th>描述</th></tr></thead><tbody><tr><td><code>CI</code></td><td>始终设置为 <code>true</code></td></tr><tr><td><code>HOME</code></td><td>用于存储用户数据的 GitHub 主目录路径。 例如 <code>/github/home</code></td></tr><tr><td><code>GITHUB_WORKFLOW</code></td><td>工作流程的名称。</td></tr><tr><td><code>GITHUB_RUN_ID</code></td><td>仓库中每个运行的唯一编号。 如果您重新执行工作流程运行,此编号不变。</td></tr><tr><td><code>GITHUB_RUN_NUMBER</code></td><td>仓库中特定工作流程每个运行的唯一编号。 此编号从 1(对应于工作流程的第一个运行)开始,然后随着每个新的运行而递增。 如果您重新执行工作流程运行,此编号不变。</td></tr><tr><td><code>GITHUB_ACTION</code></td><td>操作唯一的标识符 (id)。</td></tr><tr><td><code>GITHUB_ACTIONS</code></td><td>当 GitHub 操作 运行工作流程时,始终设置为 true。 您可以使用此变量来区分测试是在本地运行还是通过 GitHub 操作 运行。</td></tr><tr><td><code>GITHUB_ACTION_PATH</code></td><td>GitHub 操作所在的路径</td></tr><tr><td><code>GITHUB_ACTOR</code></td><td>发起工作流程的个人或应用程序的名称。 例如 octocat</td></tr><tr><td><code>GITHUB_API_URL</code></td><td>返回 <code>API URL</code>。例如:<code>https://api.github.com</code></td></tr><tr><td><code>GITHUB_REPOSITORY</code></td><td>所有者和仓库名称。 例如 octocat/Hello-World</td></tr><tr><td><code>GITHUB_EVENT_NAME</code></td><td>触发工作流程的 web 挂钩事件的名称</td></tr><tr><td><code>GITHUB_EVENT_PATH</code></td><td>具有完整 web 挂钩事件有效负载的文件路径。 例如 /github/workflow/event.json</td></tr><tr><td><code>GITHUB_WORKSPACE</code></td><td>GitHub 工作空间目录路径。 如果您的工作流程使用 <a href="https://github.com/actions/checkout">actions/checkout</a> 操作,工作空间目录将包含存储仓库副本的子目录。 如果不使用 <a href="https://github.com/actions/checkout">actions/checkout</a> 操作,该目录将为空。 例如 /home</td></tr><tr><td><code>GITHUB_SHA</code></td><td>触发工作流程的提交 SHA。 例如 ffac537e6cbbf9</td></tr><tr><td><code>GITHUB_REF</code></td><td>触发工作流程的分支或标记参考。 例如 refs/heads/feature-branch-1。 如果分支或标记都不适用于事件类型,则变量不会存在</td></tr><tr><td><code>GITHUB_HEAD_REF</code></td><td>仅为复刻的仓库设置。头部仓库的分支</td></tr><tr><td><code>GITHUB_BASE_REF</code></td><td>仅为复刻的仓库设置。基础仓库的分支</td></tr></tbody></table>
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/environment-variables#default-environment-variables">默认环境变量</a></p>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="直接常量"><a aria-hidden="true" tabindex="-1" href="#直接常量"><span class="icon icon-link"></span></a>直接常量</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="直接常量"><a aria-hidden="true" tabindex="-1" href="#直接常量"><span class="icon icon-link"></span></a>直接常量</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<p>作为表达式的一部分,可以使用 <code>boolean</code>, <code>null</code>, <code>number</code> 或 <code>string</code>数据类型</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">env</span><span class="token punctuation">:</span>
|
||||
@ -469,7 +469,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">myString</span><span class="token punctuation">:</span> Mona the Octocat
|
||||
</span><span class="code-line"> <span class="token key atrule">myStringInBraces</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> 'It''s source<span class="token tag">!'</span> <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="函数-contains"><a aria-hidden="true" tabindex="-1" href="#函数-contains"><span class="icon icon-link"></span></a>函数 contains</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="函数-contains"><a aria-hidden="true" tabindex="-1" href="#函数-contains"><span class="icon icon-link"></span></a>函数 contains</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<p>使用字符串的示例</p>
|
||||
<pre class="language-js"><code class="language-js code-highlight"><span class="code-line"><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">'Hello world'</span><span class="token punctuation">,</span> <span class="token string">'llo'</span><span class="token punctuation">)</span> <span class="token comment">// 返回 true</span>
|
||||
@ -479,27 +479,27 @@
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#contains">函数 contains</a></p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-startswith"><a aria-hidden="true" tabindex="-1" href="#函数-startswith"><span class="icon icon-link"></span></a>函数 startsWith</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-startswith"><a aria-hidden="true" tabindex="-1" href="#函数-startswith"><span class="icon icon-link"></span></a>函数 startsWith</h3><div class="wrap-body">
|
||||
<pre class="language-js"><code class="language-js code-highlight"><span class="code-line"><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">'Hello world'</span><span class="token punctuation">,</span> <span class="token string">'He'</span><span class="token punctuation">)</span> <span class="token comment">// 返回 true</span>
|
||||
</span></code></pre>
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#startswith">函数 startsWith</a>,此函数不区分大小写</p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-format"><a aria-hidden="true" tabindex="-1" href="#函数-format"><span class="icon icon-link"></span></a>函数 format</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-format"><a aria-hidden="true" tabindex="-1" href="#函数-format"><span class="icon icon-link"></span></a>函数 format</h3><div class="wrap-body">
|
||||
<pre class="wrap-text "><code class="language-js code-highlight"><span class="code-line"><span class="token function">format</span><span class="token punctuation">(</span><span class="token string">'{{Hello {0} {1} {2}!}}'</span><span class="token punctuation">,</span> <span class="token string">'Mona'</span><span class="token punctuation">,</span> <span class="token string">'the'</span><span class="token punctuation">,</span> <span class="token string">'Octocat'</span><span class="token punctuation">)</span>
|
||||
</span><span class="code-line"><span class="token comment">// 返回 '{Hello Mona the Octocat!}'.</span>
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#format">函数 format</a></p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-join"><a aria-hidden="true" tabindex="-1" href="#函数-join"><span class="icon icon-link"></span></a>函数 join</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-join"><a aria-hidden="true" tabindex="-1" href="#函数-join"><span class="icon icon-link"></span></a>函数 join</h3><div class="wrap-body">
|
||||
<pre class="language-js"><code class="language-js code-highlight"><span class="code-line"><span class="token function">join</span><span class="token punctuation">(</span>github<span class="token punctuation">.</span><span class="token property-access">event</span><span class="token punctuation">.</span><span class="token property-access">issue</span><span class="token punctuation">.</span><span class="token property-access">labels</span><span class="token punctuation">.</span><span class="token operator">*</span><span class="token punctuation">.</span><span class="token property-access">name</span><span class="token punctuation">,</span> <span class="token string">', '</span><span class="token punctuation">)</span>
|
||||
</span><span class="code-line"><span class="token comment">// 也许返回 'bug, help wanted'.</span>
|
||||
</span></code></pre>
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#join">函数 join</a></p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-tojson"><a aria-hidden="true" tabindex="-1" href="#函数-tojson"><span class="icon icon-link"></span></a>函数 toJSON</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-tojson"><a aria-hidden="true" tabindex="-1" href="#函数-tojson"><span class="icon icon-link"></span></a>函数 toJSON</h3><div class="wrap-body">
|
||||
<pre class="language-js"><code class="language-js code-highlight"><span class="code-line"><span class="token function">toJSON</span><span class="token punctuation">(</span>job<span class="token punctuation">)</span>
|
||||
</span><span class="code-line"><span class="token comment">// 也许返回 { "status": "Success" }.</span>
|
||||
</span></code></pre>
|
||||
<p>另见: <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#tojson">函数 toJSON</a></p>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="函数"><a aria-hidden="true" tabindex="-1" href="#函数"><span class="icon icon-link"></span></a>函数</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="函数"><a aria-hidden="true" tabindex="-1" href="#函数"><span class="icon icon-link"></span></a>函数</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
|
||||
@ -535,20 +535,20 @@
|
||||
|
||||
|
||||
<table><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>fromJSON</code></td><td align="left">返回 JSON 对象或 JSON 数据类型的值 <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#fromjson">#</a></td></tr><tr><td align="left"><code>hashFiles</code></td><td align="left">返回与路径模式匹配的文件集的单个哈希 <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#hashfiles">#</a></td></tr><tr><td align="left"><code>success</code></td><td align="left">当前面的步骤都没失败或被取消时返回 true <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#success">#</a></td></tr><tr><td align="left"><code>always</code></td><td align="left">使步骤始终执行,返回 <code>true</code> 即使取消也是如此 <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#always">#</a></td></tr><tr><td align="left"><code>cancelled</code></td><td align="left">如果工作流被取消,则返回 true <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#cancelled">#</a></td></tr><tr><td align="left"><code>failure</code></td><td align="left">当作业的任何先前步骤失败时返回 true <a href="https://docs.github.com/cn/actions/learn-github-actions/expressions#failure">#</a></td></tr></tbody></table>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-success"><a aria-hidden="true" tabindex="-1" href="#函数-success"><span class="icon icon-link"></span></a>函数 success()</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-success"><a aria-hidden="true" tabindex="-1" href="#函数-success"><span class="icon icon-link"></span></a>函数 success()</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">steps</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">...</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> The job has succeeded
|
||||
</span><span class="code-line"> <span class="token key atrule">if</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> success() <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="函数-failure"><a aria-hidden="true" tabindex="-1" href="#函数-failure"><span class="icon icon-link"></span></a>函数 failure()</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="函数-failure"><a aria-hidden="true" tabindex="-1" href="#函数-failure"><span class="icon icon-link"></span></a>函数 failure()</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">steps</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">...</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> The job has failed
|
||||
</span><span class="code-line"> <span class="token key atrule">if</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> failure() <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div></div></div><div class="wrap"><div class="wrap-header h2wrap"><h2 id="常用实例"><a aria-hidden="true" tabindex="-1" href="#常用实例"><span class="icon icon-link"></span></a>常用实例</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap col-span-2"><div class="wrap-header h3wrap"><h3 id="获取版本信息"><a aria-hidden="true" tabindex="-1" href="#获取版本信息"><span class="icon icon-link"></span></a>获取版本信息</h3><div class="wrap-body">
|
||||
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="常用实例"><a aria-hidden="true" tabindex="-1" href="#常用实例"><span class="icon icon-link"></span></a>常用实例</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="获取版本信息"><a aria-hidden="true" tabindex="-1" href="#获取版本信息"><span class="icon icon-link"></span></a>获取版本信息</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<pre class="wrap-text "><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Test
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> <span class="token punctuation">|</span><span class="token scalar string">
|
||||
@ -561,14 +561,14 @@
|
||||
</span><span class="code-line"> echo "$VERSION"
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="提交到-gh-pages-分支"><a aria-hidden="true" tabindex="-1" href="#提交到-gh-pages-分支"><span class="icon icon-link"></span></a>提交到 gh-pages 分支</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="提交到-gh-pages-分支"><a aria-hidden="true" tabindex="-1" href="#提交到-gh-pages-分支"><span class="icon icon-link"></span></a>提交到 gh-pages 分支</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Deploy
|
||||
</span><span class="code-line"> <span class="token key atrule">uses</span><span class="token punctuation">:</span> peaceiris/actions<span class="token punctuation">-</span>gh<span class="token punctuation">-</span>pages@v3
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">github_token</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span>secrets.GITHUB_TOKEN<span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">publish_dir</span><span class="token punctuation">:</span> ./build
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="修改-packagejson"><a aria-hidden="true" tabindex="-1" href="#修改-packagejson"><span class="icon icon-link"></span></a>修改 package.json</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="修改-packagejson"><a aria-hidden="true" tabindex="-1" href="#修改-packagejson"><span class="icon icon-link"></span></a>修改 package.json</h3><div class="wrap-body">
|
||||
<pre class="wrap-text "><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Modify Version
|
||||
</span><span class="code-line"> <span class="token key atrule">shell</span><span class="token punctuation">:</span> bash
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> <span class="token punctuation">|</span><span class="token scalar string">
|
||||
@ -581,7 +581,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">rename</span><span class="token punctuation">:</span> <span class="token string">'@wcj/github-package-test'</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="克隆带有-submodule-的仓库"><a aria-hidden="true" tabindex="-1" href="#克隆带有-submodule-的仓库"><span class="icon icon-link"></span></a>克隆带有 Submodule 的仓库</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="克隆带有-submodule-的仓库"><a aria-hidden="true" tabindex="-1" href="#克隆带有-submodule-的仓库"><span class="icon icon-link"></span></a>克隆带有 Submodule 的仓库</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Checkout
|
||||
</span><span class="code-line"> <span class="token key atrule">uses</span><span class="token punctuation">:</span> actions/checkout@v3
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
@ -596,7 +596,7 @@
|
||||
</span></span><span class="code-line"><span class="token scalar string"> # git submodule sync --recursive
|
||||
</span></span><span class="code-line"><span class="token scalar string"> # git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --remote --force --recursive --checkout ant.design</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="步骤依赖作业"><a aria-hidden="true" tabindex="-1" href="#步骤依赖作业"><span class="icon icon-link"></span></a>步骤依赖作业</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="步骤依赖作业"><a aria-hidden="true" tabindex="-1" href="#步骤依赖作业"><span class="icon icon-link"></span></a>步骤依赖作业</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<p>使用 <code>jobs.<job_id>.needs</code> 识别在此作业运行之前必须成功完成的任何作业。它可以是一个字符串,也可以是字符串数组。 如果某个作业失败,则所有需要它的作业都会被跳过,除非这些作业使用让该作业继续的条件表达式。</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
@ -621,7 +621,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">needs</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>job1<span class="token punctuation">,</span> job2<span class="token punctuation">]</span>
|
||||
</span></code></pre>
|
||||
<p>在此示例中,<code>job3</code> 使用 <code>always()</code> 条件表达式,因此它始终在 <code>job1</code> 和 <code>job2</code> 完成后运行,不管它们是否成功。</p>
|
||||
</div></div></div><div class="wrap col-span-2"><div class="wrap-header h3wrap"><h3 id="同步-gitee"><a aria-hidden="true" tabindex="-1" href="#同步-gitee"><span class="icon icon-link"></span></a>同步 Gitee</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="同步-gitee"><a aria-hidden="true" tabindex="-1" href="#同步-gitee"><span class="icon icon-link"></span></a>同步 Gitee</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<pre class="wrap-text "><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Sync to Gitee
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> <span class="token punctuation">|</span><span class="token scalar string">
|
||||
@ -636,7 +636,7 @@
|
||||
</span></span><span class="code-line"><span class="token scalar string"> mirror uiwjs uiw</span>
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="提交-npm-包"><a aria-hidden="true" tabindex="-1" href="#提交-npm-包"><span class="icon icon-link"></span></a>提交 NPM 包</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="提交-npm-包"><a aria-hidden="true" tabindex="-1" href="#提交-npm-包"><span class="icon icon-link"></span></a>提交 NPM 包</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm publish <span class="token punctuation">-</span><span class="token punctuation">-</span>access public
|
||||
</span><span class="code-line"> <span class="token key atrule">env</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">NODE_AUTH_TOKEN</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span>secrets.NPM_TOKEN<span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
@ -655,7 +655,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">package</span><span class="token punctuation">:</span> packages/data/package.json
|
||||
</span></code></pre>
|
||||
<p>它有个好处,检测 <code>package.json</code> 中版本号是否发生变更,来决定是否提交版本,不会引发流程错误。</p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="步骤作业文件共享"><a aria-hidden="true" tabindex="-1" href="#步骤作业文件共享"><span class="icon icon-link"></span></a>步骤作业文件共享</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="步骤作业文件共享"><a aria-hidden="true" tabindex="-1" href="#步骤作业文件共享"><span class="icon icon-link"></span></a>步骤作业文件共享</h3><div class="wrap-body">
|
||||
<p>Artifacts 是 GitHub Actions 为您提供持久文件并在运行完成后使用它们或在作业(文档)之间共享的一种方式。</p>
|
||||
<p>要创建工件并使用它,您将需要不同的操作:上传和下载。
|
||||
要上传文件或目录,您只需像这样使用它:</p>
|
||||
@ -675,7 +675,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">name</span><span class="token punctuation">:</span> my<span class="token punctuation">-</span>artifact
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="nodejs"><a aria-hidden="true" tabindex="-1" href="#nodejs"><span class="icon icon-link"></span></a>Node.js</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="nodejs"><a aria-hidden="true" tabindex="-1" href="#nodejs"><span class="icon icon-link"></span></a>Node.js</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Setup Node
|
||||
</span><span class="code-line"> <span class="token key atrule">uses</span><span class="token punctuation">:</span> actions/setup<span class="token punctuation">-</span>node@v2
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
@ -696,7 +696,7 @@
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm run build <span class="token punctuation">-</span><span class="token punctuation">-</span>if<span class="token punctuation">-</span>present
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">run</span><span class="token punctuation">:</span> npm test
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap col-span-2 row-span-2"><div class="wrap-header h3wrap"><h3 id="提交-docker-镜像"><a aria-hidden="true" tabindex="-1" href="#提交-docker-镜像"><span class="icon icon-link"></span></a>提交 docker 镜像</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2 row-span-2"><div class="wrap-header h3wrap"><h3 id="提交-docker-镜像"><a aria-hidden="true" tabindex="-1" href="#提交-docker-镜像"><span class="icon icon-link"></span></a>提交 docker 镜像</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token comment"># https://www.basefactor.com/github-actions-docker</span>
|
||||
</span><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Docker login
|
||||
@ -719,7 +719,7 @@
|
||||
</span><span class="code-line"> docker push $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.DOCKER_USER <span class="token punctuation">}</span><span class="token punctuation">}</span>/ant.design<span class="token punctuation">:</span>$VERSION
|
||||
</span><span class="code-line"> docker push $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.DOCKER_USER <span class="token punctuation">}</span><span class="token punctuation">}</span>/ant.design<span class="token punctuation">:</span>latest
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="创建一个-tag"><a aria-hidden="true" tabindex="-1" href="#创建一个-tag"><span class="icon icon-link"></span></a>创建一个 tag</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="创建一个-tag"><a aria-hidden="true" tabindex="-1" href="#创建一个-tag"><span class="icon icon-link"></span></a>创建一个 tag</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Create Tag
|
||||
</span><span class="code-line"> <span class="token key atrule">id</span><span class="token punctuation">:</span> create_tag
|
||||
</span><span class="code-line"> <span class="token key atrule">uses</span><span class="token punctuation">:</span> jaywcjlove/create<span class="token punctuation">-</span>tag<span class="token punctuation">-</span>action@main
|
||||
@ -727,7 +727,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">package-path</span><span class="token punctuation">:</span> ./package.json
|
||||
</span></code></pre>
|
||||
<p>根据 <code>package-path</code> 指定的 <code>package.json</code> 检测 <code>version</code> 是否发生变化来创建 <code>tag</code></p>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="生成-git-提交日志"><a aria-hidden="true" tabindex="-1" href="#生成-git-提交日志"><span class="icon icon-link"></span></a>生成 git 提交日志</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="生成-git-提交日志"><a aria-hidden="true" tabindex="-1" href="#生成-git-提交日志"><span class="icon icon-link"></span></a>生成 git 提交日志</h3><div class="wrap-body">
|
||||
<pre class="wrap-text "><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Generate Changelog
|
||||
</span><span class="code-line"> <span class="token key atrule">id</span><span class="token punctuation">:</span> changelog
|
||||
</span><span class="code-line"> <span class="token key atrule">uses</span><span class="token punctuation">:</span> jaywcjlove/changelog<span class="token punctuation">-</span>generator@main
|
||||
@ -738,7 +738,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> echo "$<span class="token punctuation">{</span><span class="token punctuation">{</span> steps.changelog.outputs.changelog <span class="token punctuation">}</span><span class="token punctuation">}</span>"
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
</div></div></div><div class="wrap col-span-3"><div class="wrap-header h3wrap"><h3 id="提交到-github-docker-镜像仓库"><a aria-hidden="true" tabindex="-1" href="#提交到-github-docker-镜像仓库"><span class="icon icon-link"></span></a>提交到 GitHub docker 镜像仓库</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-3"><div class="wrap-header h3wrap"><h3 id="提交到-github-docker-镜像仓库"><a aria-hidden="true" tabindex="-1" href="#提交到-github-docker-镜像仓库"><span class="icon icon-link"></span></a>提交到 GitHub docker 镜像仓库</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> <span class="token string">'登录到 GitHub 注册表'</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> echo $<span class="token punctuation">{</span><span class="token punctuation">{</span> github.token <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token punctuation">|</span> docker login ghcr.io <span class="token punctuation">-</span>u $<span class="token punctuation">{</span><span class="token punctuation">{</span> github.actor <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token punctuation">-</span><span class="token punctuation">-</span>password<span class="token punctuation">-</span>stdin
|
||||
@ -756,7 +756,7 @@
|
||||
</span></span><span class="code-line"><span class="token scalar string"> docker tag ghcr.io/jaywcjlove/reference:latest ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
|
||||
</span></span><span class="code-line"><span class="token scalar string"> docker push ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap col-span-2"><div class="wrap-header h3wrap"><h3 id="提交-commit-到-master-分支"><a aria-hidden="true" tabindex="-1" href="#提交-commit-到-master-分支"><span class="icon icon-link"></span></a>提交 commit 到 master 分支</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="提交-commit-到-master-分支"><a aria-hidden="true" tabindex="-1" href="#提交-commit-到-master-分支"><span class="icon icon-link"></span></a>提交 commit 到 master 分支</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> 生成一个文件,并将它提交到 master 分支
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> <span class="token punctuation">|</span><span class="token scalar string">
|
||||
@ -783,7 +783,7 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">github_token</span><span class="token punctuation">:</span> $<span class="token punctuation">{</span><span class="token punctuation">{</span> secrets.GITHUB_TOKEN <span class="token punctuation">}</span><span class="token punctuation">}</span>
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="作业之间共享数据"><a aria-hidden="true" tabindex="-1" href="#作业之间共享数据"><span class="icon icon-link"></span></a>作业之间共享数据</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="作业之间共享数据"><a aria-hidden="true" tabindex="-1" href="#作业之间共享数据"><span class="icon icon-link"></span></a>作业之间共享数据</h3><div class="wrap-body">
|
||||
<p>创建一个文件,然后将其作为构件上传</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">example-job</span><span class="token punctuation">:</span>
|
||||
@ -807,13 +807,13 @@
|
||||
</span><span class="code-line"> <span class="token key atrule">with</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">name</span><span class="token punctuation">:</span> output<span class="token punctuation">-</span>log<span class="token punctuation">-</span>file
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="指定运行命令的工作目录"><a aria-hidden="true" tabindex="-1" href="#指定运行命令的工作目录"><span class="icon icon-link"></span></a>指定运行命令的工作目录</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="指定运行命令的工作目录"><a aria-hidden="true" tabindex="-1" href="#指定运行命令的工作目录"><span class="icon icon-link"></span></a>指定运行命令的工作目录</h3><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Clean temp directory
|
||||
</span><span class="code-line"> <span class="token key atrule">run</span><span class="token punctuation">:</span> rm <span class="token punctuation">-</span>rf *
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">working-directory</span><span class="token punctuation">:</span> ./temp
|
||||
</span></code></pre>
|
||||
<p>使用 <code>working-directory</code> 关键字,您可以指定运行命令的工作目录(<code>./temp</code>)</p>
|
||||
</div></div><div class="h3wrap-body"><div class="wrap"><div class="wrap-header h4wrap"><h4 id="defaultsrun"><a aria-hidden="true" tabindex="-1" href="#defaultsrun"><span class="icon icon-link"></span></a>defaults.run</h4><div class="wrap-body">
|
||||
</div></div><div class="h3wrap-body"><div class="wrap h4body-not-exist"><div class="wrap-header h4wrap"><h4 id="defaultsrun"><a aria-hidden="true" tabindex="-1" href="#defaultsrun"><span class="icon icon-link"></span></a>defaults.run</h4><div class="wrap-body">
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">jobs</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">job1</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token key atrule">runs-on</span><span class="token punctuation">:</span> ubuntu<span class="token punctuation">-</span>latest
|
||||
@ -823,7 +823,7 @@
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">working-directory</span><span class="token punctuation">:</span> scripts
|
||||
</span></code></pre>
|
||||
<p>作业中的所有 <code>run</code> 步骤提供默认的 <code>shell</code> 和 <code>working-directory</code></p>
|
||||
</div></div></div></div></div><div class="wrap"><div class="wrap-header h3wrap"><h3 id="jobsjob_idstepsshell"><a aria-hidden="true" tabindex="-1" href="#jobsjob_idstepsshell"><span class="icon icon-link"></span></a>jobs.<job_id>.steps[*].shell</h3><div class="wrap-body">
|
||||
</div></div></div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="jobsjob_idstepsshell"><a aria-hidden="true" tabindex="-1" href="#jobsjob_idstepsshell"><span class="icon icon-link"></span></a>jobs.<job_id>.steps[*].shell</h3><div class="wrap-body">
|
||||
<p>使用 <code>bash</code> 运行脚本</p>
|
||||
<pre class="language-yml"><code class="language-yml code-highlight"><span class="code-line"><span class="token key atrule">steps</span><span class="token punctuation">:</span>
|
||||
</span><span class="code-line"> <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Display the path
|
||||
@ -839,7 +839,7 @@
|
||||
</span><span class="code-line highlight-line"> <span class="token key atrule">shell</span><span class="token punctuation">:</span> python
|
||||
</span></code></pre>
|
||||
<p>您可以使用 <code>shell</code> 关键字覆盖运行器操作系统中的默认 <code>shell</code> 设置</p>
|
||||
</div></div></div><div class="wrap row-span-2"><div class="wrap-header h3wrap"><h3 id="一些-actions-推荐"><a aria-hidden="true" tabindex="-1" href="#一些-actions-推荐"><span class="icon icon-link"></span></a>一些 actions 推荐</h3><div class="wrap-body">
|
||||
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="一些-actions-推荐"><a aria-hidden="true" tabindex="-1" href="#一些-actions-推荐"><span class="icon icon-link"></span></a>一些 actions 推荐</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
|
||||
@ -896,7 +896,7 @@
|
||||
|
||||
<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><a href="https://github.com/jaywcjlove/create-tag-action"><code>create-tag-action</code></a></td><td align="left">根据 package.json 创建 <code>Tag</code> / <code>Release</code></td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/changelog-generator"><code>changelog-generator</code></a></td><td align="left">生成 <code>changelog</code> 日志</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/github-action-modify-file-content"><code>github-action-modify-file-content</code></a></td><td align="left">修改仓库文件内容</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/github-action-contributors"><code>github-action-contributors</code></a></td><td align="left">生成贡献(contributors.svg)图片</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/generated-badges"><code>generated-badges</code></a></td><td align="left">生成徽章(Badges)图片</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/coverage-badges-cli"><code>coverage-badges-cli</code></a></td><td align="left">生成覆盖率徽章(Badges)图片</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/action-ejs"><code>action-ejs</code></a></td><td align="left">基于 ejs 生成 HTML</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/github-action-package"><code>github-action-package</code></a></td><td align="left">修改 JSON 文件内容</td></tr><tr><td align="left"><a href="https://github.com/jaywcjlove/markdown-to-html-cli"><code>markdown-to-html-cli</code></a></td><td align="left">Markdown 转换成 HTML</td></tr><tr><td align="left"><a href="https://github.com/ncipollo/release-action"><code>ncipollo/release-action</code></a></td><td align="left">创建 <code>Release</code></td></tr><tr><td align="left"><a href="https://github.com/peaceiris/actions-gh-pages"><code>peaceiris/actions-gh-pages</code></a></td><td align="left">将文件或文件夹内容提交到 <code>gh-pages</code> 分支</td></tr></tbody></table>
|
||||
<!--rehype:className=style-list-->
|
||||
</div></div></div></div></div><div class="wrap"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
|
||||
</div></div></div></div></div><div class="wrap h2body-not-exist"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
|
||||
<ul>
|
||||
<li><a href="https://jaywcjlove.github.io/github-actions">Github Actions 学习笔记</a> <em>(jaywcjlove.github.io)</em></li>
|
||||
<li><a href="https://docs.github.com/cn/actions/learn-github-actions">了解 GitHub Actions</a> <em>(docs.github.com)</em></li>
|
||||
@ -914,8 +914,6 @@ function anchorPoint() {
|
||||
Array.from(document.querySelectorAll('.h2wrap-body .wrap')).forEach((elm) => elm.classList.remove('active'))
|
||||
if (elm?.tagName === 'H3') {
|
||||
elm?.parentElement?.parentElement?.classList.add('active');
|
||||
const box = elm?.parentElement?.parentElement;
|
||||
console.log('elm:2', box, document.querySelectorAll('.h2wrap-body .wrap'))
|
||||
}
|
||||
}
|
||||
anchorPoint();
|
||||
@ -926,7 +924,6 @@ function updateAnchor(element) {
|
||||
tocanchor.classList.remove('is-active-link');
|
||||
});
|
||||
const anchor = element || document.querySelector(`a.tocs-link[href='${decodeURIComponent(window.location.hash)}']`);
|
||||
console.log('anchor', anchor)
|
||||
if (anchor) {
|
||||
anchor.classList.add('is-active-link');
|
||||
}
|
||||
|
Reference in New Issue
Block a user