Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f795e92af9 | ||
|
|
e46ec802f8 | ||
|
|
f2e802cdcd | ||
|
|
e02b7d7dab | ||
|
|
9881e80bfd | ||
|
|
a824931115 | ||
|
|
cc12dc0f23 | ||
|
|
13bd9c8b43 | ||
|
|
231937b397 |
18
.github/docker-releases.json
vendored
18
.github/docker-releases.json
vendored
@@ -1,14 +1,20 @@
|
|||||||
{
|
{
|
||||||
"latest": {
|
"latest": {
|
||||||
"id": 190678909,
|
"id": 194138446,
|
||||||
"tag_name": "v27.4.1",
|
"tag_name": "v27.5.0",
|
||||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.4.1",
|
"html_url": "https://github.com/moby/moby/releases/tag/v27.5.0",
|
||||||
|
"assets": []
|
||||||
|
},
|
||||||
|
"v27.5.0": {
|
||||||
|
"id": 194138446,
|
||||||
|
"tag_name": "v27.5.0",
|
||||||
|
"html_url": "https://github.com/moby/moby/releases/tag/v27.5.0",
|
||||||
"assets": []
|
"assets": []
|
||||||
},
|
},
|
||||||
"edge": {
|
"edge": {
|
||||||
"id": 193567140,
|
"id": 194138446,
|
||||||
"tag_name": "v27.5.0-rc.2",
|
"tag_name": "v27.5.0",
|
||||||
"html_url": "https://github.com/moby/moby/releases/tag/v27.5.0-rc.2",
|
"html_url": "https://github.com/moby/moby/releases/tag/v27.5.0",
|
||||||
"assets": []
|
"assets": []
|
||||||
},
|
},
|
||||||
"v27.5.0-rc.2": {
|
"v27.5.0-rc.2": {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {describe, expect, jest, it, afterEach} from '@jest/globals';
|
import {describe, expect, jest, it, afterEach, beforeEach, test} from '@jest/globals';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
@@ -44,6 +44,34 @@ describe('gitRef', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parseGitRef', () => {
|
||||||
|
const originalEnv = process.env;
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {
|
||||||
|
...originalEnv,
|
||||||
|
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''
|
||||||
|
};
|
||||||
|
});
|
||||||
|
afterEach(() => {
|
||||||
|
process.env = originalEnv;
|
||||||
|
});
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
['refs/heads/master', '860c1904a1ce19322e91ac35af1ab07466440c37', false, '860c1904a1ce19322e91ac35af1ab07466440c37'],
|
||||||
|
['master', '860c1904a1ce19322e91ac35af1ab07466440c37', false, '860c1904a1ce19322e91ac35af1ab07466440c37'],
|
||||||
|
['refs/pull/15/merge', '860c1904a1ce19322e91ac35af1ab07466440c37', false, 'refs/pull/15/merge'],
|
||||||
|
['refs/heads/master', '', false, 'refs/heads/master'],
|
||||||
|
['master', '', false, 'master'],
|
||||||
|
['refs/tags/v1.0.0', '', false, 'refs/tags/v1.0.0'],
|
||||||
|
['refs/pull/15/merge', '', false, 'refs/pull/15/merge'],
|
||||||
|
['refs/pull/15/merge', '', true, 'refs/pull/15/head'],
|
||||||
|
])('given %p and %p, should return %p', async (ref: string, sha: string, prHeadRef: boolean, expected: string) => {
|
||||||
|
process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF = prHeadRef ? 'true' : '';
|
||||||
|
expect(Context.parseGitRef(ref, sha)).toEqual(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('gitContext', () => {
|
describe('gitContext', () => {
|
||||||
it('returns refs/heads/master', async () => {
|
it('returns refs/heads/master', async () => {
|
||||||
expect(Context.gitContext()).toEqual('https://github.com/docker/actions-toolkit.git#refs/heads/master');
|
expect(Context.gitContext()).toEqual('https://github.com/docker/actions-toolkit.git#refs/heads/master');
|
||||||
|
|||||||
@@ -14,23 +14,44 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
ARG ADDLICENSE_VERSION="v1.1.1"
|
||||||
|
ARG ALPINE_VERSION="3.21"
|
||||||
|
ARG GO_VERSION="1.23"
|
||||||
|
ARG XX_VERSION="1.6.1"
|
||||||
|
|
||||||
ARG LICENSE_HOLDER="actions-toolkit authors"
|
ARG LICENSE_HOLDER="actions-toolkit authors"
|
||||||
ARG LICENSE_TYPE="apache"
|
ARG LICENSE_TYPE="apache"
|
||||||
ARG LICENSE_FILES=".*\(Dockerfile\|Makefile\|\.js\|\.ts\|\.hcl\|\.sh|\.ps1\)"
|
ARG LICENSE_FILES=".*\(Dockerfile\|Makefile\|\.js\|\.ts\|\.hcl\|\.sh|\.ps1\)"
|
||||||
ARG ADDLICENSE_VERSION="v1.0.0"
|
|
||||||
|
|
||||||
FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||||
|
|
||||||
FROM alpine:3.17 AS base
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||||
WORKDIR /src
|
|
||||||
RUN apk add --no-cache cpio findutils git
|
RUN apk add --no-cache cpio findutils git
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
WORKDIR /src
|
||||||
|
COPY --link --from=xx / /
|
||||||
|
|
||||||
|
FROM base AS addlicense
|
||||||
|
ARG ADDLICENSE_VERSION
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
RUN --mount=target=/root/.cache,type=cache \
|
||||||
|
--mount=type=cache,target=/go/pkg/mod <<EOT
|
||||||
|
set -ex
|
||||||
|
xx-go install "github.com/google/addlicense@${ADDLICENSE_VERSION}"
|
||||||
|
mkdir /out
|
||||||
|
if ! xx-info is-cross; then
|
||||||
|
mv /go/bin/addlicense /out
|
||||||
|
else
|
||||||
|
mv /go/bin/*/addlicense* /out
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM base AS set
|
FROM base AS set
|
||||||
ARG LICENSE_HOLDER
|
ARG LICENSE_HOLDER
|
||||||
ARG LICENSE_TYPE
|
ARG LICENSE_TYPE
|
||||||
ARG LICENSE_FILES
|
ARG LICENSE_FILES
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
|
--mount=from=addlicense,source=/out/addlicense,target=/usr/bin/addlicense \
|
||||||
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE" && \
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE" && \
|
||||||
mkdir /out && \
|
mkdir /out && \
|
||||||
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | cpio -pdm /out
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | cpio -pdm /out
|
||||||
@@ -43,5 +64,5 @@ ARG LICENSE_HOLDER
|
|||||||
ARG LICENSE_TYPE
|
ARG LICENSE_TYPE
|
||||||
ARG LICENSE_FILES
|
ARG LICENSE_FILES
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \
|
--mount=from=addlicense,source=/out/addlicense,target=/usr/bin/addlicense \
|
||||||
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -check -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE"
|
find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -check -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE"
|
||||||
|
|||||||
@@ -39,23 +39,23 @@ export class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static gitRef(): string {
|
public static gitRef(): string {
|
||||||
let gitRef = github.context.ref;
|
return Context.parseGitRef(github.context.ref, github.context.sha);
|
||||||
if (github.context.sha && gitRef && !gitRef.startsWith('refs/')) {
|
}
|
||||||
gitRef = `refs/heads/${github.context.ref}`;
|
|
||||||
|
public static parseGitRef(ref: string, sha: string): string {
|
||||||
|
const setPullRequestHeadRef: boolean = !!(process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF && process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF === 'true');
|
||||||
|
if (sha && ref && !ref.startsWith('refs/')) {
|
||||||
|
ref = `refs/heads/${ref}`;
|
||||||
}
|
}
|
||||||
if (github.context.sha && !gitRef.startsWith(`refs/pull/`)) {
|
if (sha && !ref.startsWith(`refs/pull/`)) {
|
||||||
gitRef = github.context.sha;
|
ref = sha;
|
||||||
} else if (gitRef.startsWith(`refs/pull/`)) {
|
} else if (ref.startsWith(`refs/pull/`) && setPullRequestHeadRef) {
|
||||||
gitRef = gitRef.replace(/\/merge$/g, '/head');
|
ref = ref.replace(/\/merge$/g, '/head');
|
||||||
}
|
}
|
||||||
return gitRef;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static gitContext(): string {
|
public static gitContext(): string {
|
||||||
return `${GitHub.serverURL}/${github.context.repo.owner}/${github.context.repo.repo}.git#${Context.gitRef()}`;
|
return `${GitHub.serverURL}/${github.context.repo.owner}/${github.context.repo.repo}.git#${Context.gitRef()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static provenanceBuilderID(): string {
|
|
||||||
return `${GitHub.serverURL}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user