mirror of
https://github.com/actions/checkout.git
synced 2025-09-16 12:42:20 +08:00
Compare commits
1 Commits
5c521f3d4b
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
1b0793cc05 |
@@ -17,4 +17,4 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@0.0.3
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
2
.github/workflows/update-test-ubuntu-git.yml
vendored
2
.github/workflows/update-test-ubuntu-git.yml
vendored
@@ -48,7 +48,7 @@ jobs:
|
|||||||
|
|
||||||
# Use `docker/build-push-action` to build (and optionally publish) the image.
|
# Use `docker/build-push-action` to build (and optionally publish) the image.
|
||||||
- name: Build Docker Image (with optional Push)
|
- name: Build Docker Image (with optional Push)
|
||||||
uses: docker/build-push-action@v6.5.0
|
uses: docker/build-push-action@v6.10.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: images/test-ubuntu-git.Dockerfile
|
file: images/test-ubuntu-git.Dockerfile
|
||||||
|
14
README.md
14
README.md
@@ -29,11 +29,6 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
# Otherwise, uses the default branch.
|
# Otherwise, uses the default branch.
|
||||||
ref: ''
|
ref: ''
|
||||||
|
|
||||||
# Indicates whether to checkout the default repository branch if the requested ref
|
|
||||||
# does not exist
|
|
||||||
# Default: false
|
|
||||||
default-branch-checkout: ''
|
|
||||||
|
|
||||||
# Personal access token (PAT) used to fetch the repository. The PAT is configured
|
# Personal access token (PAT) used to fetch the repository. The PAT is configured
|
||||||
# with the local git config, which enables your scripts to run authenticated git
|
# with the local git config, which enables your scripts to run authenticated git
|
||||||
# commands. The post-job step removes the PAT.
|
# commands. The post-job step removes the PAT.
|
||||||
@@ -316,17 +311,8 @@ jobs:
|
|||||||
git commit -m "generated"
|
git commit -m "generated"
|
||||||
git push
|
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
|
*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
|
||||||
|
|
||||||
# Recommended permissions
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
```
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
@@ -815,7 +815,6 @@ async function setup(testName: string): Promise<void> {
|
|||||||
nestedSubmodules: false,
|
nestedSubmodules: false,
|
||||||
persistCredentials: true,
|
persistCredentials: true,
|
||||||
ref: 'refs/heads/main',
|
ref: 'refs/heads/main',
|
||||||
defaultBranchCheckout: false,
|
|
||||||
repositoryName: 'my-repo',
|
repositoryName: 'my-repo',
|
||||||
repositoryOwner: 'my-org',
|
repositoryOwner: 'my-org',
|
||||||
repositoryPath: '',
|
repositoryPath: '',
|
||||||
|
@@ -80,7 +80,6 @@ describe('input-helper tests', () => {
|
|||||||
expect(settings.commit).toBeTruthy()
|
expect(settings.commit).toBeTruthy()
|
||||||
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
|
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
|
||||||
expect(settings.filter).toBe(undefined)
|
expect(settings.filter).toBe(undefined)
|
||||||
expect(settings.defaultBranchCheckout).toBe(false)
|
|
||||||
expect(settings.sparseCheckout).toBe(undefined)
|
expect(settings.sparseCheckout).toBe(undefined)
|
||||||
expect(settings.sparseCheckoutConeMode).toBe(true)
|
expect(settings.sparseCheckoutConeMode).toBe(true)
|
||||||
expect(settings.fetchDepth).toBe(1)
|
expect(settings.fetchDepth).toBe(1)
|
||||||
|
@@ -9,9 +9,6 @@ inputs:
|
|||||||
The branch, tag or SHA to checkout. When checking out the repository that
|
The branch, tag or SHA to checkout. When checking out the repository that
|
||||||
triggered a workflow, this defaults to the reference or SHA for that
|
triggered a workflow, this defaults to the reference or SHA for that
|
||||||
event. Otherwise, uses the default branch.
|
event. Otherwise, uses the default branch.
|
||||||
default-branch-checkout:
|
|
||||||
description: 'Indicates whether to checkout the default repository branch if the requested ref does not exist'
|
|
||||||
default: false
|
|
||||||
token:
|
token:
|
||||||
description: >
|
description: >
|
||||||
Personal access token (PAT) used to fetch the repository. The PAT is configured
|
Personal access token (PAT) used to fetch the repository. The PAT is configured
|
||||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@@ -1278,7 +1278,7 @@ function getSource(settings) {
|
|||||||
else if (settings.sparseCheckout) {
|
else if (settings.sparseCheckout) {
|
||||||
fetchOptions.filter = 'blob:none';
|
fetchOptions.filter = 'blob:none';
|
||||||
}
|
}
|
||||||
if (settings.fetchDepth <= 0 || settings.defaultBranchCheckout) {
|
if (settings.fetchDepth <= 0) {
|
||||||
// Fetch all branches and tags
|
// Fetch all branches and tags
|
||||||
let refSpec = refHelper.getRefSpecForAllHistory(settings.ref, settings.commit);
|
let refSpec = refHelper.getRefSpecForAllHistory(settings.ref, settings.commit);
|
||||||
yield git.fetch(refSpec, fetchOptions);
|
yield git.fetch(refSpec, fetchOptions);
|
||||||
@@ -1298,22 +1298,7 @@ function getSource(settings) {
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
// Checkout info
|
// Checkout info
|
||||||
core.startGroup('Determining the checkout info');
|
core.startGroup('Determining the checkout info');
|
||||||
let checkoutInfo;
|
const checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit);
|
||||||
try {
|
|
||||||
checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if (settings.defaultBranchCheckout) {
|
|
||||||
core.info('Could not determine the checkout info. Trying the default repository branch');
|
|
||||||
const repositoryDefaultBranch = settings.sshKey
|
|
||||||
? yield git.getDefaultBranch(repositoryUrl)
|
|
||||||
: yield githubApiHelper.getDefaultBranch(settings.authToken, settings.repositoryOwner, settings.repositoryName);
|
|
||||||
checkoutInfo = yield refHelper.getCheckoutInfo(git, repositoryDefaultBranch, settings.commit);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
// LFS fetch
|
// LFS fetch
|
||||||
// Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
|
// Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
|
||||||
@@ -1778,11 +1763,6 @@ function getInputs() {
|
|||||||
}
|
}
|
||||||
core.debug(`ref = '${result.ref}'`);
|
core.debug(`ref = '${result.ref}'`);
|
||||||
core.debug(`commit = '${result.commit}'`);
|
core.debug(`commit = '${result.commit}'`);
|
||||||
// Default branch checkout
|
|
||||||
result.defaultBranchCheckout =
|
|
||||||
(core.getInput('default-branch-checkout') || 'false').toUpperCase() ===
|
|
||||||
'TRUE';
|
|
||||||
core.debug(`default-branch-checkout = '${result.defaultBranchCheckout}'`);
|
|
||||||
// Clean
|
// Clean
|
||||||
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE';
|
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE';
|
||||||
core.debug(`clean = ${result.clean}`);
|
core.debug(`clean = ${result.clean}`);
|
||||||
|
@@ -169,7 +169,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
fetchOptions.filter = 'blob:none'
|
fetchOptions.filter = 'blob:none'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.fetchDepth <= 0 || settings.defaultBranchCheckout) {
|
if (settings.fetchDepth <= 0) {
|
||||||
// Fetch all branches and tags
|
// Fetch all branches and tags
|
||||||
let refSpec = refHelper.getRefSpecForAllHistory(
|
let refSpec = refHelper.getRefSpecForAllHistory(
|
||||||
settings.ref,
|
settings.ref,
|
||||||
@@ -193,34 +193,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
|
|
||||||
// Checkout info
|
// Checkout info
|
||||||
core.startGroup('Determining the checkout info')
|
core.startGroup('Determining the checkout info')
|
||||||
let checkoutInfo: refHelper.ICheckoutInfo
|
const checkoutInfo = await refHelper.getCheckoutInfo(
|
||||||
try {
|
|
||||||
checkoutInfo = await refHelper.getCheckoutInfo(
|
|
||||||
git,
|
git,
|
||||||
settings.ref,
|
settings.ref,
|
||||||
settings.commit
|
settings.commit
|
||||||
)
|
)
|
||||||
} catch (error) {
|
|
||||||
if (settings.defaultBranchCheckout) {
|
|
||||||
core.info(
|
|
||||||
'Could not determine the checkout info. Trying the default repository branch'
|
|
||||||
)
|
|
||||||
const repositoryDefaultBranch = settings.sshKey
|
|
||||||
? await git.getDefaultBranch(repositoryUrl)
|
|
||||||
: await githubApiHelper.getDefaultBranch(
|
|
||||||
settings.authToken,
|
|
||||||
settings.repositoryOwner,
|
|
||||||
settings.repositoryName
|
|
||||||
)
|
|
||||||
checkoutInfo = await refHelper.getCheckoutInfo(
|
|
||||||
git,
|
|
||||||
repositoryDefaultBranch,
|
|
||||||
settings.commit
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
// LFS fetch
|
// LFS fetch
|
||||||
|
@@ -19,11 +19,6 @@ export interface IGitSourceSettings {
|
|||||||
*/
|
*/
|
||||||
ref: string
|
ref: string
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether to checkout the default repository branch if the requested ref does not exist
|
|
||||||
*/
|
|
||||||
defaultBranchCheckout: boolean
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The commit to checkout
|
* The commit to checkout
|
||||||
*/
|
*/
|
||||||
|
@@ -78,12 +78,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
core.debug(`ref = '${result.ref}'`)
|
core.debug(`ref = '${result.ref}'`)
|
||||||
core.debug(`commit = '${result.commit}'`)
|
core.debug(`commit = '${result.commit}'`)
|
||||||
|
|
||||||
// Default branch checkout
|
|
||||||
result.defaultBranchCheckout =
|
|
||||||
(core.getInput('default-branch-checkout') || 'false').toUpperCase() ===
|
|
||||||
'TRUE'
|
|
||||||
core.debug(`default-branch-checkout = '${result.defaultBranchCheckout}'`)
|
|
||||||
|
|
||||||
// Clean
|
// Clean
|
||||||
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
|
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
|
||||||
core.debug(`clean = ${result.clean}`)
|
core.debug(`clean = ${result.clean}`)
|
||||||
|
Reference in New Issue
Block a user