1
0
Fork 0
mirror of https://code.forgejo.org/actions/checkout.git synced 2025-04-04 13:57:48 +02:00

Update README.md

([({扩展描述   })]
This commit is contained in:
嗨,我是@80sei 我感兴趣的是 我目前正在学习 我想合作的 如何联系我 邮箱a0214691@dingtalk.com 代词 趣闻 2024-10-30 23:04:21 +08:00 committed by GitHub
parent 11bd71901b
commit a7c1755241
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

474
README.md
View file

@ -1,293 +1,293 @@
[![Build and Test](https://github.com/actions/checkout/actions/workflows/test.yml/badge.svg)](https://github.com/actions/checkout/actions/workflows/test.yml) [![构建和测试](https://github.com/actions/checkout/actions/workflows/test.yml/badge.svg)](https://github.com/actions/checkout/actions/workflows/test.yml)
# Checkout V4 #签出V4
This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workflow can access it. 此操作将在下签出您的存储库`$GITHUB_WORKSPACE`,以便您的工作流可以访问它。
Only a single commit is fetched by default, for the ref/SHA that triggered the workflow. Set `fetch-depth: 0` to fetch all history for all branches and tags. Refer [here](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows) to learn which commit `$GITHUB_SHA` points to for different events. 对于触发工作流的ref/SHA默认情况下只提取一个提交。一组`提取深度:0`获取所有分支和标签的所有历史记录。参考[这里](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows)为了了解哪个提交`$GITHUB_SHA`指向不同的事件。
The auth token is persisted in the local git config. This enables your scripts to run authenticated git commands. The token is removed during post-job cleanup. Set `persist-credentials: false` to opt-out. auth令牌保存在本地git配置中。这使您的脚本能够运行经过身份验证的git命令。该令牌在作业后清理过程中被删除。一组`坚持-凭据:错误`选择退出。
When Git 2.18 or higher is not in your PATH, falls back to the REST API to download the files. 当Git 2.18或更高版本不在您的路径中时回退到REST API来下载文件。
# What's new #怎么样
Please refer to the [release page](https://github.com/actions/checkout/releases/latest) for the latest release notes. 请参考[发布页面](https://github.com/actions/checkout/releases/latest)获取最新的发行说明。
# Usage #使用
<!-- start usage --> <!-开始使用->
```yaml ```亚姆
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: 使用:
# Repository name with owner. For example, actions/checkout #带有所有者的存储库名称。例如,动作/签出
# Default: ${{ github.repository }} # Default:$ { { github。知识库} }
repository: '' 存储库:“”
# The branch, tag or SHA to checkout. When checking out the repository that #要结帐的分支、标签或SHA。当签出存储库时
# triggered a workflow, this defaults to the reference or SHA for that event. #触发了工作流这默认为该事件的参考或SHA。
# Otherwise, uses the default branch. #否则,使用默认分支。
ref: '' 引用:“”
# Personal access token (PAT) used to fetch the repository. The PAT is configured #用于获取存储库的个人访问令牌(PAT)。PAT已配置
# with the local git config, which enables your scripts to run authenticated git #使用本地git配置,这使您的脚本能够运行经过身份验证的git
# commands. The post-job step removes the PAT. #命令。作业后步骤移除PAT。
# #
# We recommend using a service account with the least permissions necessary. Also #我们建议使用所需权限最少的服务帐户。也
# when generating a new PAT, select the least scopes necessary. #生成新PAT时,选择最少的必要范围。
# #
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) #[了解有关创建和使用加密机密的更多信息](https://help . github . com/en/actions/automating-your-workflow-with-github-actions/creating-and-use-encrypted-secrets)
# #
# Default: ${{ github.token }} # Default: ${{ github.token }}
token: '' 令牌:“”
# SSH key used to fetch the repository. The SSH key is configured with the local #用于获取存储库的SSH密钥。SSH密钥是用本地配置的
# git config, which enables your scripts to run authenticated git commands. The # git config它使您的脚本能够运行经过身份验证的git命令。这
# post-job step removes the SSH key. #作业后步骤删除SSH密钥
# #
# We recommend using a service account with the least permissions necessary. #我们建议使用所需权限最少的服务帐户
# #
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) #[了解有关创建和使用加密机密的更多信息](https://help . github . com/en/actions/automating-your-workflow-with-github-actions/creating-and-use-encrypted-secrets)
ssh-key: '' ssh-key:" "
# Known hosts in addition to the user and global host key database. The public SSH #除用户和全局主机密钥数据库之外的已知主机。公开的宋承宪
# keys for a host may be obtained using the utility `ssh-keyscan`. For example, #可以使用实用程序“ssh-keyscan”获得主机的密钥。举个例子
# `ssh-keyscan github.com`. The public key for github.com is always implicitly # ` ssh-keyscan github。com `github.com的公钥总是隐式的
# added. #已添加
ssh-known-hosts: '' 嘘已知主机:""
# Whether to perform strict host key checking. When true, adds the options #是否执行严格的主机密钥检查。为真时,添加选项
# `StrictHostKeyChecking=yes` and `CheckHostIP=no` to the SSH command line. Use # `StrictHostKeyChecking=yes '和` CheckHostIP =否'到嘘命令行。使用
# the input `ssh-known-hosts` to configure additional hosts. #输入“嘘——已知主机"来配置其他主机。
# Default: true #默认值:真
ssh-strict: '' ssh-strict:" "
# The user to use when connecting to the remote SSH host. By default 'git' is #连接到远程SSH主机时使用的用户。默认情况下“git”是
# used. #已使用
# Default: git #默认值:git
ssh-user: '' ssh-用户:“”
# Whether to configure the token or SSH key with the local git config #是否使用本地git配置来配置令牌或SSH密钥
# Default: true #默认值:真
persist-credentials: '' 持久凭据:“”
# Relative path under $GITHUB_WORKSPACE to place the repository #放置存储库的GITHUB _ WORKSPACE下的相对路径
path: '' 路径:“”
# Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching #何鸿燊的《去清理ffdx &去重置硬盘头》
# Default: true #默认值:真
clean: '' 清理:“”
# Partially clone against a given filter. Overrides sparse-checkout if set. #根据给定的过滤器部分克隆。如果设置,则覆盖稀疏校验。
# Default: null #默认值:空
filter: '' 筛选器:“”
# Do a sparse checkout on given patterns. Each pattern should be separated with #对给定的模式进行稀疏校验。每个模式都应该用
# new lines. #新线条
# Default: null #默认值:空
sparse-checkout: '' 稀疏签出:“”
# Specifies whether to use cone-mode when doing a sparse checkout. #指定执行稀疏检出时是否使用锥形模式
# Default: true #默认值:真
sparse-checkout-cone-mode: '' 稀疏校验锥形模式:“”
# Number of commits to fetch. 0 indicates all history for all branches and tags. #要提取的提交数量。0表示所有分支和标记的所有历史记录。
# Default: 1 #默认值:1
fetch-depth: '' 提取深度:“”
# Whether to fetch tags, even if fetch-depth > 0. #是否提取标记,即使提取深度> 0。
# Default: false #默认值:假
fetch-tags: '' 提取标记:“”
# Whether to show progress status output when fetching. #提取时是否显示进度状态输出
# Default: true #默认值:真
show-progress: '' 显示进度:“”
# Whether to download Git-LFS files #是否下载吉特-LFS文件
# Default: false #默认值:假
lfs: '' lfs:" "
# Whether to checkout submodules: `true` to checkout submodules or `recursive` to #是否签出子模块:`真的'表示签出子模块,或`递归'表示
# recursively checkout submodules. #递归签出子模块
# #
# When the `ssh-key` input is not provided, SSH URLs beginning with #当没有提供" ssh-key "输入时SSH URLs以
# `git@github.com:` are converted to HTTPS. # `git@github.com:`皈依HTTPS教。
# #
# Default: false #默认值:假
submodules: '' 子模块:“”
# Add repository path as safe.directory for Git global config by running `git #通过运行“git”将存储库路径添加为饭桶全局配置的safe.directory
# config --global --add safe.directory <path>` #配置-全局-添加保险箱。目录<路径>`
# Default: true #默认值:真
set-safe-directory: '' set-safe-directory:" "
# The base URL for the GitHub instance that you are trying to clone from, will use #您尝试从中克隆的开源代码库实例的基本统一资源定位器将使用
# environment defaults to fetch from the same instance that the workflow is #环境默认从工作流所在的同一实例中提取
# running from unless specified. Example URLs are https://github.com or #除非特别说明,否则从开始运行网址。的例子有https://github.com或
# https://my-ghes-server.example.com # https://my-ghes-server.example.com
github-server-url: '' github-服务器-url:" "
``` ```
<!-- end usage --> <!-结束使用-->
# Scenarios #情节
- [Fetch only the root files](#Fetch-only-the-root-files) - [仅获取根文件](#只提取根文件)
- [Fetch only the root files and `.github` and `src` folder](#Fetch-only-the-root-files-and-github-and-src-folder) - [只获取根文件`。开源代码库`和`科学研究委员会`文件夹](#只取根文件和github-和-src-文件夹)
- [Fetch only a single file](#Fetch-only-a-single-file) - [仅获取一个文件](#只取一个文件)
- [Fetch all history for all tags and branches](#Fetch-all-history-for-all-tags-and-branches) - [获取所有标签和分支的所有历史记录](#获取所有标签和分支的所有历史记录)
- [Checkout a different branch](#Checkout-a-different-branch) - [签出不同的分支](#结帐-不同的分行)
- [Checkout HEAD^](#Checkout-HEAD) - [结账头](#结帐头)
- [Checkout multiple repos (side by side)](#Checkout-multiple-repos-side-by-side) - [签出多个回购(并排)](#结帐-多个回购-并排)
- [Checkout multiple repos (nested)](#Checkout-multiple-repos-nested) - [签出多个回购(嵌套)](#结帐-多重回购-嵌套)
- [Checkout multiple repos (private)](#Checkout-multiple-repos-private) - [签出多个回购(私有)](#结帐-多次回购-私人)
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit) - [签出拉请求头提交而不是合并提交](#检查出-拉出-请求-头部-提交-合并-提交)
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event) - [已关闭事件的签出请求](#结帐-拉取-关闭时请求-事件)
- [Push a commit using the built-in token](#Push-a-commit-using-the-built-in-token) - [使用内置令牌推送提交](#使用内置令牌推送提交)
## Fetch only the root files ##仅获取根文件
```亚姆
- uses: actions/checkout@v4
使用:
稀疏检出:。
```
##只获取根文件`。开源代码库``科学研究委员会`文件夹
```亚姆
- uses: actions/checkout@v4
使用:
稀疏校验:
。开源代码库
科学研究委员会
```
##仅获取一个文件
```亚姆
- uses: actions/checkout@v4
使用:
稀疏校验:
README.md
稀疏校验圆锥模式:假
```
##获取所有标签和分支的所有历史记录
```亚姆
- uses: actions/checkout@v4
使用:
提取深度:0
```
##签出不同的分支
```亚姆
- uses: actions/checkout@v4
使用:
参考:我的分行
```
##结账头
```亚姆
- uses: actions/checkout@v4
使用:
提取深度:2
-运行:git结帐头
```
##签出多个回购(并排)
```亚姆
-名称:结帐
用途:动作/结帐@v4
使用:
路径:主路径
-名称:结帐工具回购
用途:动作/结帐@v4
使用:
存储库:我的组织/我的工具
路径:我的工具
```
> -如果您的辅助存储库是私有的,您需要添加中注明的选项[签出多个回购(私有)](#结帐-多次回购-私人)
##签出多个回购(嵌套)
```亚姆
-名称:结帐
用途:动作/结帐@v4
-名称:结帐工具回购
用途:动作/结帐@v4
使用:
存储库:我的组织/我的工具
路径:我的工具
```
> -如果您的辅助存储库是私有的,您需要添加中注明的选项[签出多个回购(私有)](#结帐-多次回购-私人)
##签出多个回购(私有)
```亚姆
-名称:结帐
用途:动作/结帐@v4
使用:
路径:主路径
-名称:结账专用工具
用途:动作/结帐@v4
使用:
存储库:我的组织/我的私有工具
令牌:${{机密。GH_PAT }} # `GH_PAT '是包含您的小块的秘密
路径:我的工具
```
> - `${{ github.token }}`的范围是当前存储库,所以如果您想签出一个不同的私有存储库,您需要提供自己的存储库[小块](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
##签出拉请求头提交而不是合并提交
```yaml ```yaml
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: 使用:
sparse-checkout: . ref:$ { { github。事件。拉取请求。头。sha } }
``` ```
## Fetch only the root files and `.github` and `src` folder ##已关闭事件的签出请求
```yaml ```yaml
开启:
拉取请求:
分支:[主]
类型:[打开、同步、关闭]
工作:
构建:
运行:Ubuntu-最新版
步骤:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
sparse-checkout: |
.github
src
``` ```
## Fetch only a single file ##使用内置令牌推送提交
```yaml ```yaml
开:推
工作:
构建:
运行:Ubuntu-最新版
步骤:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: -运行:
sparse-checkout: | date > generated.txt
README.md #注意以下帐户信息不适用于GHES
sparse-checkout-cone-mode: false 饭桶配置user.name "github-actions[bot]"
饭桶配置用户。邮箱" 41898282+github-actions[bot]@用户。没有回复github .com "
饭桶添加。
饭桶提交-m "生成"
饭桶推送
``` ```
*注意:*用户电子邮件是`{user.id}+{user.login}@users.noreply.github.com`。请参阅用户应用程序接口:https://api.github.com/users/github-actions%5Bbot%5D
## Fetch all history for all tags and branches #许可证
```yaml 这个项目中的脚本和文档发布在[麻省理工学院许可证](许可证)
- uses: actions/checkout@v4
with:
fetch-depth: 0
```
## Checkout a different branch
```yaml
- uses: actions/checkout@v4
with:
ref: my-branch
```
## Checkout HEAD^
```yaml
- uses: actions/checkout@v4
with:
fetch-depth: 2
- run: git checkout HEAD^
```
## Checkout multiple repos (side by side)
```yaml
- name: Checkout
uses: actions/checkout@v4
with:
path: main
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: my-org/my-tools
path: my-tools
```
> - If your secondary repository is private you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
## Checkout multiple repos (nested)
```yaml
- name: Checkout
uses: actions/checkout@v4
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: my-org/my-tools
path: my-tools
```
> - If your secondary repository is private you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
## Checkout multiple repos (private)
```yaml
- name: Checkout
uses: actions/checkout@v4
with:
path: main
- name: Checkout private tools
uses: actions/checkout@v4
with:
repository: my-org/my-private-tools
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
path: my-tools
```
> - `${{ github.token }}` is scoped to the current repository, so if you want to checkout a different repository that is private you will need to provide your own [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
## Checkout pull request HEAD commit instead of merge commit
```yaml
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
```
## Checkout pull request on closed event
```yaml
on:
pull_request:
branches: [main]
types: [opened, synchronize, closed]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
```
## Push a commit using the built-in token
```yaml
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
date > generated.txt
# Note: the following account information will not work on GHES
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "generated"
git push
```
*NOTE:* The user email is `{user.id}+{user.login}@users.noreply.github.com`. See users API: https://api.github.com/users/github-actions%5Bbot%5D
# License
The scripts and documentation in this project are released under the [MIT License](LICENSE)