Skip to content

Commit 5023bfa

Browse files
authored
Add files via upload
1 parent 57fff2e commit 5023bfa

1 file changed

Lines changed: 363 additions & 0 deletions

File tree

actions/README.md

Lines changed: 363 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,363 @@
1+
[![Build and Test](https://github.com/actions/checkout/actions/workflows/test.yml/badge.svg)](https://github.com/actions/checkout/actions/workflows/test.yml)
2+
3+
# Checkout V5
4+
5+
## What's new
6+
7+
- Updated to the node24 runtime
8+
- This requires a minimum Actions Runner version of [v2.327.1](https://github.com/actions/runner/releases/tag/v2.327.1) to run.
9+
10+
11+
# Checkout V4
12+
13+
This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workflow can access it.
14+
15+
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.
16+
17+
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.
18+
19+
When Git 2.18 or higher is not in your PATH, falls back to the REST API to download the files.
20+
21+
### Note
22+
23+
Thank you for your interest in this GitHub action, however, right now we are not taking contributions.
24+
25+
We continue to focus our resources on strategic areas that help our customers be successful while making developers' lives easier. While GitHub Actions remains a key part of this vision, we are allocating resources towards other areas of Actions and are not taking contributions to this repository at this time. The GitHub public roadmap is the best place to follow along for any updates on features we’re working on and what stage they’re in.
26+
27+
We are taking the following steps to better direct requests related to GitHub Actions, including:
28+
29+
1. We will be directing questions and support requests to our [Community Discussions area](https://github.com/orgs/community/discussions/categories/actions)
30+
31+
2. High Priority bugs can be reported through Community Discussions or you can report these to our support team https://support.github.com/contact/bug-report.
32+
33+
3. Security Issues should be handled as per our [security.md](security.md)
34+
35+
We will still provide security updates for this project and fix major breaking changes during this time.
36+
37+
You are welcome to still raise bugs in this repo.
38+
39+
# What's new
40+
41+
Please refer to the [release page](https://github.com/actions/checkout/releases/latest) for the latest release notes.
42+
43+
# Usage
44+
45+
<!-- start usage -->
46+
```yaml
47+
- uses: actions/checkout@v5
48+
with:
49+
# Repository name with owner. For example, actions/checkout
50+
# Default: ${{ github.repository }}
51+
repository: ''
52+
53+
# The branch, tag or SHA to checkout. When checking out the repository that
54+
# triggered a workflow, this defaults to the reference or SHA for that event.
55+
# Otherwise, uses the default branch.
56+
ref: ''
57+
58+
# Personal access token (PAT) used to fetch the repository. The PAT is configured
59+
# with the local git config, which enables your scripts to run authenticated git
60+
# commands. The post-job step removes the PAT.
61+
#
62+
# We recommend using a service account with the least permissions necessary. Also
63+
# when generating a new PAT, select the least scopes necessary.
64+
#
65+
# [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)
66+
#
67+
# Default: ${{ github.token }}
68+
token: ''
69+
70+
# SSH key used to fetch the repository. The SSH key is configured with the local
71+
# git config, which enables your scripts to run authenticated git commands. The
72+
# post-job step removes the SSH key.
73+
#
74+
# We recommend using a service account with the least permissions necessary.
75+
#
76+
# [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)
77+
ssh-key: ''
78+
79+
# Known hosts in addition to the user and global host key database. The public SSH
80+
# keys for a host may be obtained using the utility `ssh-keyscan`. For example,
81+
# `ssh-keyscan github.com`. The public key for github.com is always implicitly
82+
# added.
83+
ssh-known-hosts: ''
84+
85+
# Whether to perform strict host key checking. When true, adds the options
86+
# `StrictHostKeyChecking=yes` and `CheckHostIP=no` to the SSH command line. Use
87+
# the input `ssh-known-hosts` to configure additional hosts.
88+
# Default: true
89+
ssh-strict: ''
90+
91+
# The user to use when connecting to the remote SSH host. By default 'git' is
92+
# used.
93+
# Default: git
94+
ssh-user: ''
95+
96+
# Whether to configure the token or SSH key with the local git config
97+
# Default: true
98+
persist-credentials: ''
99+
100+
# Relative path under $GITHUB_WORKSPACE to place the repository
101+
path: ''
102+
103+
# Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching
104+
# Default: true
105+
clean: ''
106+
107+
# Partially clone against a given filter. Overrides sparse-checkout if set.
108+
# Default: null
109+
filter: ''
110+
111+
# Do a sparse checkout on given patterns. Each pattern should be separated with
112+
# new lines.
113+
# Default: null
114+
sparse-checkout: ''
115+
116+
# Specifies whether to use cone-mode when doing a sparse checkout.
117+
# Default: true
118+
sparse-checkout-cone-mode: ''
119+
120+
# Number of commits to fetch. 0 indicates all history for all branches and tags.
121+
# Default: 1
122+
fetch-depth: ''
123+
124+
# Whether to fetch tags, even if fetch-depth > 0.
125+
# Default: false
126+
fetch-tags: ''
127+
128+
# Whether to show progress status output when fetching.
129+
# Default: true
130+
show-progress: ''
131+
132+
# Whether to download Git-LFS files
133+
# Default: false
134+
lfs: ''
135+
136+
# Whether to checkout submodules: `true` to checkout submodules or `recursive` to
137+
# recursively checkout submodules.
138+
#
139+
# When the `ssh-key` input is not provided, SSH URLs beginning with
140+
# `git@github.com:` are converted to HTTPS.
141+
#
142+
# Default: false
143+
submodules: ''
144+
145+
# Add repository path as safe.directory for Git global config by running `git
146+
# config --global --add safe.directory <path>`
147+
# Default: true
148+
set-safe-directory: ''
149+
150+
# The base URL for the GitHub instance that you are trying to clone from, will use
151+
# environment defaults to fetch from the same instance that the workflow is
152+
# running from unless specified. Example URLs are https://github.com or
153+
# https://my-ghes-server.example.com
154+
github-server-url: ''
155+
```
156+
<!-- end usage -->
157+
158+
# Scenarios
159+
160+
- [Checkout V5](#checkout-v5)
161+
- [What's new](#whats-new)
162+
- [Checkout V4](#checkout-v4)
163+
- [Note](#note)
164+
- [What's new](#whats-new-1)
165+
- [Usage](#usage)
166+
- [Scenarios](#scenarios)
167+
- [Fetch only the root files](#fetch-only-the-root-files)
168+
- [Fetch only the root files and `.github` and `src` folder](#fetch-only-the-root-files-and-github-and-src-folder)
169+
- [Fetch only a single file](#fetch-only-a-single-file)
170+
- [Fetch all history for all tags and branches](#fetch-all-history-for-all-tags-and-branches)
171+
- [Checkout a different branch](#checkout-a-different-branch)
172+
- [Checkout HEAD^](#checkout-head)
173+
- [Checkout multiple repos (side by side)](#checkout-multiple-repos-side-by-side)
174+
- [Checkout multiple repos (nested)](#checkout-multiple-repos-nested)
175+
- [Checkout multiple repos (private)](#checkout-multiple-repos-private)
176+
- [Checkout pull request HEAD commit instead of merge commit](#checkout-pull-request-head-commit-instead-of-merge-commit)
177+
- [Checkout pull request on closed event](#checkout-pull-request-on-closed-event)
178+
- [Push a commit using the built-in token](#push-a-commit-using-the-built-in-token)
179+
- [Push a commit to a PR using the built-in token](#push-a-commit-to-a-pr-using-the-built-in-token)
180+
- [Recommended permissions](#recommended-permissions)
181+
- [License](#license)
182+
183+
## Fetch only the root files
184+
185+
```yaml
186+
- uses: actions/checkout@v5
187+
with:
188+
sparse-checkout: .
189+
```
190+
191+
## Fetch only the root files and `.github` and `src` folder
192+
193+
```yaml
194+
- uses: actions/checkout@v5
195+
with:
196+
sparse-checkout: |
197+
.github
198+
src
199+
```
200+
201+
## Fetch only a single file
202+
203+
```yaml
204+
- uses: actions/checkout@v5
205+
with:
206+
sparse-checkout: |
207+
README.md
208+
sparse-checkout-cone-mode: false
209+
```
210+
211+
## Fetch all history for all tags and branches
212+
213+
```yaml
214+
- uses: actions/checkout@v5
215+
with:
216+
fetch-depth: 0
217+
```
218+
219+
## Checkout a different branch
220+
221+
```yaml
222+
- uses: actions/checkout@v5
223+
with:
224+
ref: my-branch
225+
```
226+
227+
## Checkout HEAD^
228+
229+
```yaml
230+
- uses: actions/checkout@v5
231+
with:
232+
fetch-depth: 2
233+
- run: git checkout HEAD^
234+
```
235+
236+
## Checkout multiple repos (side by side)
237+
238+
```yaml
239+
- name: Checkout
240+
uses: actions/checkout@v5
241+
with:
242+
path: main
243+
244+
- name: Checkout tools repo
245+
uses: actions/checkout@v5
246+
with:
247+
repository: my-org/my-tools
248+
path: my-tools
249+
```
250+
> - If your secondary repository is private or internal you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
251+
252+
## Checkout multiple repos (nested)
253+
254+
```yaml
255+
- name: Checkout
256+
uses: actions/checkout@v5
257+
258+
- name: Checkout tools repo
259+
uses: actions/checkout@v5
260+
with:
261+
repository: my-org/my-tools
262+
path: my-tools
263+
```
264+
> - If your secondary repository is private or internal you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
265+
266+
## Checkout multiple repos (private)
267+
268+
```yaml
269+
- name: Checkout
270+
uses: actions/checkout@v5
271+
with:
272+
path: main
273+
274+
- name: Checkout private tools
275+
uses: actions/checkout@v5
276+
with:
277+
repository: my-org/my-private-tools
278+
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
279+
path: my-tools
280+
```
281+
282+
> - `${{ 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).
283+
284+
285+
## Checkout pull request HEAD commit instead of merge commit
286+
287+
```yaml
288+
- uses: actions/checkout@v5
289+
with:
290+
ref: ${{ github.event.pull_request.head.sha }}
291+
```
292+
293+
## Checkout pull request on closed event
294+
295+
```yaml
296+
on:
297+
pull_request:
298+
branches: [main]
299+
types: [opened, synchronize, closed]
300+
jobs:
301+
build:
302+
runs-on: ubuntu-latest
303+
steps:
304+
- uses: actions/checkout@v5
305+
```
306+
307+
## Push a commit using the built-in token
308+
309+
```yaml
310+
on: push
311+
jobs:
312+
build:
313+
runs-on: ubuntu-latest
314+
steps:
315+
- uses: actions/checkout@v5
316+
- run: |
317+
date > generated.txt
318+
# Note: the following account information will not work on GHES
319+
git config user.name "github-actions[bot]"
320+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
321+
git add .
322+
git commit -m "generated"
323+
git push
324+
```
325+
*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
326+
327+
## Push a commit to a PR using the built-in token
328+
329+
In a pull request trigger, `ref` is required as GitHub Actions checks out in detached HEAD mode, meaning it doesn’t check out your branch by default.
330+
331+
```yaml
332+
on: pull_request
333+
jobs:
334+
build:
335+
runs-on: ubuntu-latest
336+
steps:
337+
- uses: actions/checkout@v5
338+
with:
339+
ref: ${{ github.head_ref }}
340+
- run: |
341+
date > generated.txt
342+
# Note: the following account information will not work on GHES
343+
git config user.name "github-actions[bot]"
344+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
345+
git add .
346+
git commit -m "generated"
347+
git push
348+
```
349+
350+
*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
351+
352+
# Recommended permissions
353+
354+
When using the `checkout` action in your GitHub Actions workflow, it is recommended to set the following `GITHUB_TOKEN` permissions to ensure proper functionality, unless alternative auth is provided via the `token` or `ssh-key` inputs:
355+
356+
```yaml
357+
permissions:
358+
contents: read
359+
```
360+
361+
# License
362+
363+
The scripts and documentation in this project are released under the [MIT License](LICENSE)

0 commit comments

Comments
 (0)