mirror of
https://github.com/actions/checkout.git
synced 2024-11-14 14:08:07 +00:00
Compare commits
3 Commits
23ec16ba49
...
b259d29fae
Author | SHA1 | Date | |
---|---|---|---|
|
b259d29fae | ||
|
b684943689 | ||
|
e832aee124 |
34
.github/workflows/test.yml
vendored
34
.github/workflows/test.yml
vendored
@ -295,3 +295,37 @@ jobs:
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
path: localClone
|
||||
|
||||
test-output:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
# Basic checkout using git
|
||||
- name: Checkout basic
|
||||
id: checkout
|
||||
uses: ./
|
||||
with:
|
||||
ref: test-data/v2/basic
|
||||
|
||||
# Verify output
|
||||
- name: Verify output
|
||||
run: |
|
||||
echo "Commit: ${{ steps.checkout.outputs.commit }}"
|
||||
echo "Ref: ${{ steps.checkout.outputs.ref }}"
|
||||
|
||||
if [ "${{ steps.checkout.outputs.ref }}" != "test-data/v2/basic" ]; then
|
||||
echo "Expected ref to be test-data/v2/basic"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${{ steps.checkout.outputs.commit }}" != "82f71901cf8c021332310dcc8cdba84c4193ff5d" ]; then
|
||||
echo "Expected commit to be 82f71901cf8c021332310dcc8cdba84c4193ff5d"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# needed to make checkout post cleanup succeed
|
||||
- name: Fix Checkout
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
@ -6,7 +6,7 @@ This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workfl
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
Set `persist-credentials: true` to opt-in to persist the auth token in the local git config. This enables your scripts to run authenticated git commands. The token is removed during post-job cleanup.
|
||||
|
||||
When Git 2.18 or higher is not in your PATH, falls back to the REST API to download the files.
|
||||
|
||||
@ -68,7 +68,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
||||
ssh-user: ''
|
||||
|
||||
# Whether to configure the token or SSH key with the local git config
|
||||
# Default: true
|
||||
# Default: false
|
||||
persist-credentials: ''
|
||||
|
||||
# Relative path under $GITHUB_WORKSPACE to place the repository
|
||||
|
@ -51,7 +51,7 @@ inputs:
|
||||
default: git
|
||||
persist-credentials:
|
||||
description: 'Whether to configure the token or SSH key with the local git config'
|
||||
default: true
|
||||
default: false
|
||||
path:
|
||||
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
|
||||
clean:
|
||||
@ -98,6 +98,11 @@ inputs:
|
||||
github-server-url:
|
||||
description: 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://my-ghes-server.example.com
|
||||
required: false
|
||||
outputs:
|
||||
ref:
|
||||
description: 'The branch, tag or SHA that was checked out'
|
||||
commit:
|
||||
description: 'The commit SHA that was checked out'
|
||||
runs:
|
||||
using: node20
|
||||
main: dist/index.js
|
||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1355,7 +1355,8 @@ function getSource(settings) {
|
||||
// Get commit information
|
||||
const commitInfo = yield git.log1();
|
||||
// Log commit sha
|
||||
yield git.log1("--format='%H'");
|
||||
const commitSHA = yield git.log1('--format=%H');
|
||||
core.setOutput('commit', commitSHA.trim());
|
||||
// Check for incorrect pull request merge commit
|
||||
yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit, settings.githubServerUrl);
|
||||
}
|
||||
@ -1897,6 +1898,7 @@ function run() {
|
||||
coreCommand.issueCommand('add-matcher', {}, path.join(__dirname, 'problem-matcher.json'));
|
||||
// Get sources
|
||||
yield gitSourceProvider.getSource(sourceSettings);
|
||||
core.setOutput('ref', sourceSettings.ref);
|
||||
}
|
||||
finally {
|
||||
// Unregister problem matcher
|
||||
|
@ -261,7 +261,8 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||
const commitInfo = await git.log1()
|
||||
|
||||
// Log commit sha
|
||||
await git.log1("--format='%H'")
|
||||
const commitSHA = await git.log1('--format=%H')
|
||||
core.setOutput('commit', commitSHA.trim())
|
||||
|
||||
// Check for incorrect pull request merge commit
|
||||
await refHelper.checkCommitInfo(
|
||||
|
@ -19,6 +19,7 @@ async function run(): Promise<void> {
|
||||
|
||||
// Get sources
|
||||
await gitSourceProvider.getSource(sourceSettings)
|
||||
core.setOutput('ref', sourceSettings.ref)
|
||||
} finally {
|
||||
// Unregister problem matcher
|
||||
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
|
||||
|
Loading…
Reference in New Issue
Block a user