mirror of
https://github.com/actions/checkout.git
synced 2025-09-11 02:02:20 +08:00
Compare commits
1 Commits
9748052ab2
...
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
|
||||||
|
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@@ -154,17 +154,6 @@ jobs:
|
|||||||
submodules: true
|
submodules: true
|
||||||
- name: Verify submodules true
|
- name: Verify submodules true
|
||||||
run: __test__/verify-submodules-true.sh
|
run: __test__/verify-submodules-true.sh
|
||||||
|
|
||||||
# Submodules limited
|
|
||||||
- name: Checkout submodules limited
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
ref: test-data/v2/submodule-ssh-url
|
|
||||||
path: submodules-true
|
|
||||||
submodules: true
|
|
||||||
submodule-directories: submodule-level-1
|
|
||||||
- name: Verify submodules true
|
|
||||||
run: __test__/verify-submodules-true.sh
|
|
||||||
|
|
||||||
# Submodules recursive
|
# Submodules recursive
|
||||||
- name: Checkout submodules recursive
|
- name: Checkout submodules recursive
|
||||||
|
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
|
||||||
|
13
README.md
13
README.md
@@ -116,10 +116,6 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
# Default: false
|
# Default: false
|
||||||
submodules: ''
|
submodules: ''
|
||||||
|
|
||||||
# A list of submodules to checkout.
|
|
||||||
# Default: null
|
|
||||||
submodule-directories: ''
|
|
||||||
|
|
||||||
# Add repository path as safe.directory for Git global config by running `git
|
# Add repository path as safe.directory for Git global config by running `git
|
||||||
# config --global --add safe.directory <path>`
|
# config --global --add safe.directory <path>`
|
||||||
# Default: true
|
# Default: true
|
||||||
@@ -315,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
|
||||||
|
|
||||||
|
@@ -813,7 +813,6 @@ async function setup(testName: string): Promise<void> {
|
|||||||
lfs: false,
|
lfs: false,
|
||||||
submodules: false,
|
submodules: false,
|
||||||
nestedSubmodules: false,
|
nestedSubmodules: false,
|
||||||
submoduleDirectories: [],
|
|
||||||
persistCredentials: true,
|
persistCredentials: true,
|
||||||
ref: 'refs/heads/main',
|
ref: 'refs/heads/main',
|
||||||
repositoryName: 'my-repo',
|
repositoryName: 'my-repo',
|
||||||
|
@@ -21,13 +21,6 @@ describe('input-helper tests', () => {
|
|||||||
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||||
return inputs[name]
|
return inputs[name]
|
||||||
})
|
})
|
||||||
// Mock getMultilineInput
|
|
||||||
jest.spyOn(core, 'getMultilineInput').mockImplementation((name: string) => {
|
|
||||||
const input: string[] = (inputs[name] || '')
|
|
||||||
.split('\n')
|
|
||||||
.filter(x => x !== '')
|
|
||||||
return input.map(inp => inp.trim())
|
|
||||||
})
|
|
||||||
|
|
||||||
// Mock error/warning/info/debug
|
// Mock error/warning/info/debug
|
||||||
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
@@ -94,7 +87,6 @@ describe('input-helper tests', () => {
|
|||||||
expect(settings.showProgress).toBe(true)
|
expect(settings.showProgress).toBe(true)
|
||||||
expect(settings.lfs).toBe(false)
|
expect(settings.lfs).toBe(false)
|
||||||
expect(settings.ref).toBe('refs/heads/some-ref')
|
expect(settings.ref).toBe('refs/heads/some-ref')
|
||||||
expect(settings.submoduleDirectories).toStrictEqual([])
|
|
||||||
expect(settings.repositoryName).toBe('some-repo')
|
expect(settings.repositoryName).toBe('some-repo')
|
||||||
expect(settings.repositoryOwner).toBe('some-owner')
|
expect(settings.repositoryOwner).toBe('some-owner')
|
||||||
expect(settings.repositoryPath).toBe(gitHubWorkspace)
|
expect(settings.repositoryPath).toBe(gitHubWorkspace)
|
||||||
@@ -152,13 +144,4 @@ describe('input-helper tests', () => {
|
|||||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
expect(settings.workflowOrganizationId).toBe(123456)
|
expect(settings.workflowOrganizationId).toBe(123456)
|
||||||
})
|
})
|
||||||
it('sets submoduleDirectories', async () => {
|
|
||||||
inputs['submodule-directories'] = 'submodule1\nsubmodule2'
|
|
||||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
|
||||||
expect(settings.submoduleDirectories).toStrictEqual([
|
|
||||||
'submodule1',
|
|
||||||
'submodule2'
|
|
||||||
])
|
|
||||||
expect(settings.submodules).toBe(true)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@@ -92,10 +92,6 @@ inputs:
|
|||||||
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
|
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
|
||||||
converted to HTTPS.
|
converted to HTTPS.
|
||||||
default: false
|
default: false
|
||||||
submodule-directories:
|
|
||||||
description: >
|
|
||||||
A list of submodules to checkout.
|
|
||||||
default: null
|
|
||||||
set-safe-directory:
|
set-safe-directory:
|
||||||
description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
|
description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
|
||||||
default: true
|
default: true
|
||||||
|
14
dist/index.js
vendored
14
dist/index.js
vendored
@@ -793,10 +793,10 @@ class GitCommandManager {
|
|||||||
yield this.execGit(args);
|
yield this.execGit(args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
submoduleUpdate(fetchDepth, recursive, submoduleDirectories) {
|
submoduleUpdate(fetchDepth, recursive) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const args = ['-c', 'protocol.version=2'];
|
const args = ['-c', 'protocol.version=2'];
|
||||||
args.push('submodule', 'update', '--init', '--force', ...submoduleDirectories);
|
args.push('submodule', 'update', '--init', '--force');
|
||||||
if (fetchDepth > 0) {
|
if (fetchDepth > 0) {
|
||||||
args.push(`--depth=${fetchDepth}`);
|
args.push(`--depth=${fetchDepth}`);
|
||||||
}
|
}
|
||||||
@@ -1340,7 +1340,7 @@ function getSource(settings) {
|
|||||||
// Checkout submodules
|
// Checkout submodules
|
||||||
core.startGroup('Fetching submodules');
|
core.startGroup('Fetching submodules');
|
||||||
yield git.submoduleSync(settings.nestedSubmodules);
|
yield git.submoduleSync(settings.nestedSubmodules);
|
||||||
yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules, settings.submoduleDirectories);
|
yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules);
|
||||||
yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
|
yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
// Persist credentials
|
// Persist credentials
|
||||||
@@ -1801,7 +1801,6 @@ function getInputs() {
|
|||||||
// Submodules
|
// Submodules
|
||||||
result.submodules = false;
|
result.submodules = false;
|
||||||
result.nestedSubmodules = false;
|
result.nestedSubmodules = false;
|
||||||
result.submoduleDirectories = [];
|
|
||||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase();
|
const submodulesString = (core.getInput('submodules') || '').toUpperCase();
|
||||||
if (submodulesString == 'RECURSIVE') {
|
if (submodulesString == 'RECURSIVE') {
|
||||||
result.submodules = true;
|
result.submodules = true;
|
||||||
@@ -1810,15 +1809,8 @@ function getInputs() {
|
|||||||
else if (submodulesString == 'TRUE') {
|
else if (submodulesString == 'TRUE') {
|
||||||
result.submodules = true;
|
result.submodules = true;
|
||||||
}
|
}
|
||||||
const submoduleDirectories = core.getMultilineInput('submodule-directories');
|
|
||||||
if (submoduleDirectories.length > 0) {
|
|
||||||
result.submoduleDirectories = submoduleDirectories;
|
|
||||||
if (!result.submodules)
|
|
||||||
result.submodules = true;
|
|
||||||
}
|
|
||||||
core.debug(`submodules = ${result.submodules}`);
|
core.debug(`submodules = ${result.submodules}`);
|
||||||
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
|
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
|
||||||
core.debug(`submodule directories = ${result.submoduleDirectories}`);
|
|
||||||
// Auth token
|
// Auth token
|
||||||
result.authToken = core.getInput('token', { required: true });
|
result.authToken = core.getInput('token', { required: true });
|
||||||
// SSH
|
// SSH
|
||||||
|
@@ -54,11 +54,7 @@ export interface IGitCommandManager {
|
|||||||
shaExists(sha: string): Promise<boolean>
|
shaExists(sha: string): Promise<boolean>
|
||||||
submoduleForeach(command: string, recursive: boolean): Promise<string>
|
submoduleForeach(command: string, recursive: boolean): Promise<string>
|
||||||
submoduleSync(recursive: boolean): Promise<void>
|
submoduleSync(recursive: boolean): Promise<void>
|
||||||
submoduleUpdate(
|
submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void>
|
||||||
fetchDepth: number,
|
|
||||||
recursive: boolean,
|
|
||||||
submoduleDirectories: string[]
|
|
||||||
): Promise<void>
|
|
||||||
submoduleStatus(): Promise<boolean>
|
submoduleStatus(): Promise<boolean>
|
||||||
tagExists(pattern: string): Promise<boolean>
|
tagExists(pattern: string): Promise<boolean>
|
||||||
tryClean(): Promise<boolean>
|
tryClean(): Promise<boolean>
|
||||||
@@ -413,19 +409,9 @@ class GitCommandManager {
|
|||||||
await this.execGit(args)
|
await this.execGit(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
async submoduleUpdate(
|
async submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> {
|
||||||
fetchDepth: number,
|
|
||||||
recursive: boolean,
|
|
||||||
submoduleDirectories: string[]
|
|
||||||
): Promise<void> {
|
|
||||||
const args = ['-c', 'protocol.version=2']
|
const args = ['-c', 'protocol.version=2']
|
||||||
args.push(
|
args.push('submodule', 'update', '--init', '--force')
|
||||||
'submodule',
|
|
||||||
'update',
|
|
||||||
'--init',
|
|
||||||
'--force',
|
|
||||||
...submoduleDirectories
|
|
||||||
)
|
|
||||||
if (fetchDepth > 0) {
|
if (fetchDepth > 0) {
|
||||||
args.push(`--depth=${fetchDepth}`)
|
args.push(`--depth=${fetchDepth}`)
|
||||||
}
|
}
|
||||||
|
@@ -242,11 +242,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
// Checkout submodules
|
// Checkout submodules
|
||||||
core.startGroup('Fetching submodules')
|
core.startGroup('Fetching submodules')
|
||||||
await git.submoduleSync(settings.nestedSubmodules)
|
await git.submoduleSync(settings.nestedSubmodules)
|
||||||
await git.submoduleUpdate(
|
await git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules)
|
||||||
settings.fetchDepth,
|
|
||||||
settings.nestedSubmodules,
|
|
||||||
settings.submoduleDirectories
|
|
||||||
)
|
|
||||||
await git.submoduleForeach(
|
await git.submoduleForeach(
|
||||||
'git config --local gc.auto 0',
|
'git config --local gc.auto 0',
|
||||||
settings.nestedSubmodules
|
settings.nestedSubmodules
|
||||||
|
@@ -74,11 +74,6 @@ export interface IGitSourceSettings {
|
|||||||
*/
|
*/
|
||||||
nestedSubmodules: boolean
|
nestedSubmodules: boolean
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates which submodule paths to checkout
|
|
||||||
*/
|
|
||||||
submoduleDirectories: string[]
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The auth token to use when fetching the repository
|
* The auth token to use when fetching the repository
|
||||||
*/
|
*/
|
||||||
|
@@ -125,7 +125,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
// Submodules
|
// Submodules
|
||||||
result.submodules = false
|
result.submodules = false
|
||||||
result.nestedSubmodules = false
|
result.nestedSubmodules = false
|
||||||
result.submoduleDirectories = []
|
|
||||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase()
|
const submodulesString = (core.getInput('submodules') || '').toUpperCase()
|
||||||
if (submodulesString == 'RECURSIVE') {
|
if (submodulesString == 'RECURSIVE') {
|
||||||
result.submodules = true
|
result.submodules = true
|
||||||
@@ -133,16 +132,9 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
} else if (submodulesString == 'TRUE') {
|
} else if (submodulesString == 'TRUE') {
|
||||||
result.submodules = true
|
result.submodules = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const submoduleDirectories = core.getMultilineInput('submodule-directories')
|
|
||||||
if (submoduleDirectories.length > 0) {
|
|
||||||
result.submoduleDirectories = submoduleDirectories
|
|
||||||
if (!result.submodules) result.submodules = true
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(`submodules = ${result.submodules}`)
|
core.debug(`submodules = ${result.submodules}`)
|
||||||
core.debug(`recursive submodules = ${result.nestedSubmodules}`)
|
core.debug(`recursive submodules = ${result.nestedSubmodules}`)
|
||||||
core.debug(`submodule directories = ${result.submoduleDirectories}`)
|
|
||||||
// Auth token
|
// Auth token
|
||||||
result.authToken = core.getInput('token', {required: true})
|
result.authToken = core.getInput('token', {required: true})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user