mirror of
https://github.com/actions/checkout.git
synced 2026-06-13 09:06:51 +08:00
Compare commits
1 Commits
fed14465db
...
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
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -40,12 +40,6 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
|||||||
#
|
#
|
||||||
# Default: ${{ github.token }}
|
# Default: ${{ github.token }}
|
||||||
token: ''
|
token: ''
|
||||||
|
|
||||||
# Github slug used to configure local user.name and user.email for git.
|
|
||||||
# This is required to push a commit from a Github Action Workflow
|
|
||||||
# Set to '' to disable this configuration
|
|
||||||
# Default: "github-action[bot]
|
|
||||||
git-config: ''
|
|
||||||
|
|
||||||
# SSH key used to fetch the repository. The SSH key is configured with the local
|
# SSH key used to fetch the repository. The SSH key is configured with the local
|
||||||
# git config, which enables your scripts to run authenticated git commands. The
|
# git config, which enables your scripts to run authenticated git commands. The
|
||||||
@@ -287,6 +281,8 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
date > generated.txt
|
date > generated.txt
|
||||||
# Note: the following account information will not work on GHES
|
# 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 add .
|
||||||
git commit -m "generated"
|
git commit -m "generated"
|
||||||
git push
|
git push
|
||||||
@@ -309,21 +305,14 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
date > generated.txt
|
date > generated.txt
|
||||||
# Note: the following account information will not work on GHES
|
# 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 add .
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,6 @@ inputs:
|
|||||||
|
|
||||||
[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)
|
[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)
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
git-user:
|
|
||||||
description: >
|
|
||||||
Github slug used to configure local user.name and user.email for git.
|
|
||||||
This is required to push a commit from a Github Action Workflow.
|
|
||||||
Set to '' to disable this configuration.
|
|
||||||
default: "github-action[bot]"
|
|
||||||
ssh-key:
|
ssh-key:
|
||||||
description: >
|
description: >
|
||||||
SSH key used to fetch the repository. The SSH key is configured with the local
|
SSH key used to fetch the repository. The SSH key is configured with the local
|
||||||
|
|||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
@@ -1813,8 +1813,6 @@ function getInputs() {
|
|||||||
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
|
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
|
||||||
// Auth token
|
// Auth token
|
||||||
result.authToken = core.getInput('token', { required: true });
|
result.authToken = core.getInput('token', { required: true });
|
||||||
// Configure user
|
|
||||||
result.gitUser = (core.getInput('git-user') || 'github-action[bot]')
|
|
||||||
// SSH
|
// SSH
|
||||||
result.sshKey = core.getInput('ssh-key');
|
result.sshKey = core.getInput('ssh-key');
|
||||||
result.sshKnownHosts = core.getInput('ssh-known-hosts');
|
result.sshKnownHosts = core.getInput('ssh-known-hosts');
|
||||||
|
|||||||
@@ -274,16 +274,6 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
settings.commit,
|
settings.commit,
|
||||||
settings.githubServerUrl
|
settings.githubServerUrl
|
||||||
)
|
)
|
||||||
if (settings.gitUser) {
|
|
||||||
if (!await git.configExists('user.name', true)) {
|
|
||||||
await git.config('user.name', settings.gitUser, true)
|
|
||||||
}
|
|
||||||
if (!await git.configExists('user.email', true)) {
|
|
||||||
|
|
||||||
const userId = await githubApiHelper.getUserId(settings.gitUser, settings.authToken, settings.githubServerUrl);
|
|
||||||
await git.config('user.email', `${userId}+${settings.gitUser}@users.noreply.github.com`, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
// Remove auth
|
// Remove auth
|
||||||
if (authHelper) {
|
if (authHelper) {
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ export interface IGitSourceSettings {
|
|||||||
*/
|
*/
|
||||||
authToken: string
|
authToken: string
|
||||||
|
|
||||||
/**
|
|
||||||
* A github user slug to set a default user name and email in the local git config
|
|
||||||
*/
|
|
||||||
gitUser: string
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SSH key to configure
|
* The SSH key to configure
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -143,15 +143,3 @@ async function downloadArchive(
|
|||||||
})
|
})
|
||||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserId(
|
|
||||||
username: string,
|
|
||||||
authToken: string,
|
|
||||||
baseUrl?: string
|
|
||||||
): Promise<number> {
|
|
||||||
const octokit = github.getOctokit(authToken, {
|
|
||||||
baseUrl: getServerApiUrl(baseUrl)
|
|
||||||
})
|
|
||||||
const user = await octokit.rest.users.getByUsername({username,});
|
|
||||||
return user.data.id
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -138,9 +138,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
// Auth token
|
// Auth token
|
||||||
result.authToken = core.getInput('token', {required: true})
|
result.authToken = core.getInput('token', {required: true})
|
||||||
|
|
||||||
// Git user
|
|
||||||
result.gitUser = core.getInput('git-user') || 'github-action[bot]'
|
|
||||||
|
|
||||||
// SSH
|
// SSH
|
||||||
result.sshKey = core.getInput('ssh-key')
|
result.sshKey = core.getInput('ssh-key')
|
||||||
result.sshKnownHosts = core.getInput('ssh-known-hosts')
|
result.sshKnownHosts = core.getInput('ssh-known-hosts')
|
||||||
|
|||||||
Reference in New Issue
Block a user