mirror of
https://gitea.com/actions/checkout.git
synced 2026-04-20 21:21:54 +08:00
Compare commits
4 Commits
v4.2.0
...
e8e821983d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8e821983d | ||
|
|
eef61447b9 | ||
|
|
6b42224f41 | ||
|
|
de5a000abf |
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
20
.github/workflows/publish-immutable-actions.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: 'Publish Immutable Action Version'
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checking out
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Publish
|
||||||
|
id: publish
|
||||||
|
uses: actions/publish-immutable-action@0.0.3
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v4.2.1
|
||||||
|
* Check out other refs/* by commit if provided, fall back to ref by @orhantoy in https://github.com/actions/checkout/pull/1924
|
||||||
|
|
||||||
## v4.2.0
|
## v4.2.0
|
||||||
|
|
||||||
* Add Ref and Commit outputs by @lucacome in https://github.com/actions/checkout/pull/1180
|
* Add Ref and Commit outputs by @lucacome in https://github.com/actions/checkout/pull/1180
|
||||||
|
|||||||
@@ -77,6 +77,16 @@ describe('ref-helper tests', () => {
|
|||||||
expect(checkoutInfo.startPoint).toBeFalsy()
|
expect(checkoutInfo.startPoint).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('getCheckoutInfo refs/ without commit', async () => {
|
||||||
|
const checkoutInfo = await refHelper.getCheckoutInfo(
|
||||||
|
git,
|
||||||
|
'refs/non-standard-ref',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
expect(checkoutInfo.ref).toBe('refs/non-standard-ref')
|
||||||
|
expect(checkoutInfo.startPoint).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
it('getCheckoutInfo unqualified branch only', async () => {
|
it('getCheckoutInfo unqualified branch only', async () => {
|
||||||
git.branchExists = jest.fn(async (remote: boolean, pattern: string) => {
|
git.branchExists = jest.fn(async (remote: boolean, pattern: string) => {
|
||||||
return true
|
return true
|
||||||
|
|||||||
31
dist/index.js
vendored
31
dist/index.js
vendored
@@ -1617,7 +1617,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
|
|||||||
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info('Retrieving the default branch name');
|
core.info('Retrieving the default branch name');
|
||||||
const octokit = github.getOctokit(authToken, {
|
const octokit = github.getOctokit(authToken, {
|
||||||
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
|
baseUrl: (0, url_helper_1.getServerApiUrl)()
|
||||||
});
|
});
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
@@ -1650,7 +1650,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
|
|||||||
function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
|
function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const octokit = github.getOctokit(authToken, {
|
const octokit = github.getOctokit(authToken, {
|
||||||
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
|
baseUrl: (0, url_helper_1.getServerApiUrl)()
|
||||||
});
|
});
|
||||||
const download = IS_WINDOWS
|
const download = IS_WINDOWS
|
||||||
? octokit.rest.repos.downloadZipballArchive
|
? octokit.rest.repos.downloadZipballArchive
|
||||||
@@ -2005,8 +2005,8 @@ function getCheckoutInfo(git, ref, commit) {
|
|||||||
result.ref = ref;
|
result.ref = ref;
|
||||||
}
|
}
|
||||||
// refs/
|
// refs/
|
||||||
else if (upperRef.startsWith('REFS/') && commit) {
|
else if (upperRef.startsWith('REFS/')) {
|
||||||
result.ref = commit;
|
result.ref = commit ? commit : ref;
|
||||||
}
|
}
|
||||||
// Unqualified ref, check for a matching branch or tag
|
// Unqualified ref, check for a matching branch or tag
|
||||||
else {
|
else {
|
||||||
@@ -2128,7 +2128,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
|
|||||||
var _a;
|
var _a;
|
||||||
try {
|
try {
|
||||||
// GHES?
|
// GHES?
|
||||||
if ((0, url_helper_1.isGhes)(baseUrl)) {
|
if ((0, url_helper_1.isGhes)()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Auth token?
|
// Auth token?
|
||||||
@@ -2174,7 +2174,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
|
|||||||
if (actualHeadSha !== expectedHeadSha) {
|
if (actualHeadSha !== expectedHeadSha) {
|
||||||
core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
|
core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
|
||||||
const octokit = github.getOctokit(token, {
|
const octokit = github.getOctokit(token, {
|
||||||
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl),
|
baseUrl: (0, url_helper_1.getServerApiUrl)(),
|
||||||
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
|
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
|
||||||
});
|
});
|
||||||
yield octokit.rest.repos.get({
|
yield octokit.rest.repos.get({
|
||||||
@@ -2459,17 +2459,16 @@ function getServerUrl(url) {
|
|||||||
: process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
: process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
||||||
return new url_1.URL(urlValue);
|
return new url_1.URL(urlValue);
|
||||||
}
|
}
|
||||||
function getServerApiUrl(url) {
|
function getServerApiUrl() {
|
||||||
let apiUrl = 'https://api.github.com';
|
return process.env['GITHUB_API_URL'] || 'https://api.github.com';
|
||||||
if (isGhes(url)) {
|
|
||||||
const serverUrl = getServerUrl(url);
|
|
||||||
apiUrl = new url_1.URL(`${serverUrl.origin}/api/v3`).toString();
|
|
||||||
}
|
|
||||||
return apiUrl;
|
|
||||||
}
|
}
|
||||||
function isGhes(url) {
|
function isGhes() {
|
||||||
const ghUrl = getServerUrl(url);
|
const ghUrl = new url_1.URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
||||||
|
const isGheHost = hostname.endsWith('.GHE.COM');
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
||||||
|
return !isGitHubHost && !isGheHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"description": "checkout action",
|
"description": "checkout action",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export async function getDefaultBranch(
|
|||||||
return await retryHelper.execute(async () => {
|
return await retryHelper.execute(async () => {
|
||||||
core.info('Retrieving the default branch name')
|
core.info('Retrieving the default branch name')
|
||||||
const octokit = github.getOctokit(authToken, {
|
const octokit = github.getOctokit(authToken, {
|
||||||
baseUrl: getServerApiUrl(baseUrl)
|
baseUrl: getServerApiUrl()
|
||||||
})
|
})
|
||||||
let result: string
|
let result: string
|
||||||
try {
|
try {
|
||||||
@@ -131,7 +131,7 @@ async function downloadArchive(
|
|||||||
baseUrl?: string
|
baseUrl?: string
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
const octokit = github.getOctokit(authToken, {
|
const octokit = github.getOctokit(authToken, {
|
||||||
baseUrl: getServerApiUrl(baseUrl)
|
baseUrl: getServerApiUrl()
|
||||||
})
|
})
|
||||||
const download = IS_WINDOWS
|
const download = IS_WINDOWS
|
||||||
? octokit.rest.repos.downloadZipballArchive
|
? octokit.rest.repos.downloadZipballArchive
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ export async function getCheckoutInfo(
|
|||||||
result.ref = ref
|
result.ref = ref
|
||||||
}
|
}
|
||||||
// refs/
|
// refs/
|
||||||
else if (upperRef.startsWith('REFS/') && commit) {
|
else if (upperRef.startsWith('REFS/')) {
|
||||||
result.ref = commit
|
result.ref = commit ? commit : ref
|
||||||
}
|
}
|
||||||
// Unqualified ref, check for a matching branch or tag
|
// Unqualified ref, check for a matching branch or tag
|
||||||
else {
|
else {
|
||||||
@@ -192,7 +192,7 @@ export async function checkCommitInfo(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// GHES?
|
// GHES?
|
||||||
if (isGhes(baseUrl)) {
|
if (isGhes()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ export async function checkCommitInfo(
|
|||||||
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
|
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
|
||||||
)
|
)
|
||||||
const octokit = github.getOctokit(token, {
|
const octokit = github.getOctokit(token, {
|
||||||
baseUrl: getServerApiUrl(baseUrl),
|
baseUrl: getServerApiUrl(),
|
||||||
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
|
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
|
||||||
'number'
|
'number'
|
||||||
)};run_id=${
|
)};run_id=${
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ export function getServerUrl(url?: string): URL {
|
|||||||
return new URL(urlValue)
|
return new URL(urlValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getServerApiUrl(url?: string): string {
|
export function getServerApiUrl(): string {
|
||||||
let apiUrl = 'https://api.github.com'
|
return process.env['GITHUB_API_URL'] || 'https://api.github.com'
|
||||||
|
|
||||||
if (isGhes(url)) {
|
|
||||||
const serverUrl = getServerUrl(url)
|
|
||||||
apiUrl = new URL(`${serverUrl.origin}/api/v3`).toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiUrl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isGhes(url?: string): boolean {
|
export function isGhes(): boolean {
|
||||||
const ghUrl = getServerUrl(url)
|
const ghUrl = new URL(
|
||||||
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
|
)
|
||||||
|
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase()
|
||||||
|
const isGitHubHost = hostname === 'GITHUB.COM'
|
||||||
|
const isGheHost = hostname.endsWith('.GHE.COM')
|
||||||
|
const isLocalHost = hostname.endsWith('.LOCALHOST')
|
||||||
|
|
||||||
|
return !isGitHubHost && !isGheHost && !isLocalHost
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user