mirror of
https://github.com/docker/metadata-action.git
synced 2025-12-16 14:29:00 +08:00
chore: adopt yarn 4 and restore context input
This commit is contained in:
parent
8d8c7c12f7
commit
ff416072d6
BIN
.yarn/releases/yarn-4.9.2.cjs
vendored
Executable file
BIN
.yarn/releases/yarn-4.9.2.cjs
vendored
Executable file
Binary file not shown.
@ -1,8 +1,6 @@
|
||||
# https://yarnpkg.com/configuration/yarnrc
|
||||
|
||||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
enableHardenedMode: true
|
||||
|
||||
logFilters:
|
||||
- code: YN0013
|
||||
@ -11,7 +9,7 @@ logFilters:
|
||||
level: discard
|
||||
- code: YN0076
|
||||
level: discard
|
||||
- code: YN0086
|
||||
level: discard
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.9.2.cjs
|
||||
|
||||
218
README.md
218
README.md
@ -1,57 +1,145 @@
|
||||
[](https://github.com/docker/metadata-action/releases/latest)
|
||||
[](https://github.com/LiquidLogicLabs/docker-metadata-action/releases/latest)
|
||||
[](https://github.com/marketplace/actions/docker-metadata-action)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=ci)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
||||
[](https://codecov.io/gh/docker/metadata-action)
|
||||
[](https://github.com/LiquidLogicLabs/docker-metadata-action/actions?workflow=ci)
|
||||
[](https://github.com/LiquidLogicLabs/docker-metadata-action/actions?workflow=test)
|
||||
[](https://codecov.io/gh/LiquidLogicLabs/docker-metadata-action)
|
||||
|
||||
## About
|
||||
|
||||
GitHub Action to extract metadata from Git reference and GitHub events. This action
|
||||
is particularly useful if used with [Docker Build Push](https://github.com/docker/build-push-action)
|
||||
> **Fork Notice**: This is a fork of [docker/metadata-action](https://github.com/docker/metadata-action) that has been modified to remove all dependencies on GitHub APIs. This allows it to work with any git repository, not just GitHub-hosted ones.
|
||||
|
||||
### Key Differences from Original
|
||||
|
||||
- **No GitHub API Dependencies**: Uses direct git commands via the `simple-git` library instead of GitHub API calls
|
||||
- **Universal Git Support**: Works with any git repository (GitHub, GitLab, Bitbucket, self-hosted, etc.)
|
||||
- **Faster Execution**: Direct git commands are faster than API calls
|
||||
- **No Rate Limits**: Doesn't consume GitHub API quota
|
||||
- **Local Testing**: Can be tested locally without GitHub connection
|
||||
- **Same Interface**: Maintains full compatibility with the original action's inputs and outputs
|
||||
|
||||
### What Was Removed
|
||||
|
||||
- `@actions/github` - GitHub API wrapper
|
||||
- `@docker/actions-toolkit` - Docker's toolkit that wraps GitHub API
|
||||
- All GitHub-specific context and event handling
|
||||
|
||||
### What Was Added
|
||||
|
||||
- `simple-git` - Clean wrapper around git CLI commands
|
||||
- Direct git repository metadata extraction
|
||||
- Local testing capabilities
|
||||
|
||||
GitHub Action to extract metadata from Git references for Docker image tagging and labeling.
|
||||
This action is particularly useful if used with [Docker Build Push](https://github.com/docker/build-push-action)
|
||||
action to tag and label Docker images.
|
||||
|
||||
### Compatibility
|
||||
|
||||
✅ **Fully Compatible**: All inputs, outputs, and functionality work exactly the same as the original action
|
||||
✅ **Universal Git**: Works with any git hosting platform (GitHub, GitLab, Bitbucket, self-hosted, etc.)
|
||||
✅ **Local Testing**: Can be tested locally using `act` or by running the scripts directly
|
||||
✅ **CI/CD Agnostic**: Works in any CI/CD system that has git access
|
||||
|
||||
### Limitations
|
||||
|
||||
⚠️ **No Pull Request Context**: PR-specific metadata is not available from git alone
|
||||
⚠️ **No GitHub Events**: GitHub event context (`push`, `pull_request`, etc.) is not available
|
||||
⚠️ **Simplified Base Ref**: `{{base_ref}}` expression may return empty in some cases
|
||||
|
||||
## Local Testing
|
||||
|
||||
You can test the action locally using [act](https://github.com/nektos/act) before pushing to GitHub:
|
||||
|
||||
### Install act
|
||||
|
||||
```bash
|
||||
# macOS
|
||||
brew install act
|
||||
|
||||
# Linux
|
||||
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
|
||||
|
||||
# Windows
|
||||
choco install act-cli
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
```bash
|
||||
# Run common tests (default)
|
||||
./act-build.sh
|
||||
|
||||
# Run specific job from a workflow
|
||||
./act-build.sh ci.yml context # Run 'context' job from ci.yml
|
||||
./act-build.sh ci.yml flavor # Run 'flavor' job from ci.yml
|
||||
|
||||
# Run all jobs in a workflow
|
||||
./act-build.sh ci.yml # Run all jobs in ci.yml
|
||||
./act-build.sh test.yml # Run all jobs in test.yml
|
||||
|
||||
# Backward compatibility - assumes ci.yml
|
||||
./act-build.sh context # Runs ci.yml context job
|
||||
|
||||
# List all workflows and jobs
|
||||
./act-build.sh list
|
||||
|
||||
# See usage and examples
|
||||
./act-build.sh help
|
||||
```
|
||||
|
||||
The script will build the action and run it through the existing GitHub Actions workflows using act,
|
||||
providing a realistic test environment that matches GitHub's infrastructure.
|
||||
|
||||

|
||||
|
||||
___
|
||||
|
||||
* [Usage](#usage)
|
||||
* [Basic](#basic)
|
||||
* [Semver](#semver)
|
||||
* [Bake definition](#bake-definition)
|
||||
* [Customizing](#customizing)
|
||||
* [inputs](#inputs)
|
||||
* [outputs](#outputs)
|
||||
* [environment variables](#environment-variables)
|
||||
* [`context` input](#context-input)
|
||||
* [`images` input](#images-input)
|
||||
* [`flavor` input](#flavor-input)
|
||||
* [`tags` input](#tags-input)
|
||||
* [`type=schedule`](#typeschedule)
|
||||
* [`type=semver`](#typesemver)
|
||||
* [`type=pep440`](#typepep440)
|
||||
* [`type=match`](#typematch)
|
||||
* [`type=edge`](#typeedge)
|
||||
* [`type=ref`](#typeref)
|
||||
* [`type=raw`](#typeraw)
|
||||
* [`type=sha`](#typesha)
|
||||
* [Notes](#notes)
|
||||
* [Image name and tag sanitization](#image-name-and-tag-sanitization)
|
||||
* [Latest tag](#latest-tag)
|
||||
* [`priority` attribute](#priority-attribute)
|
||||
* [Global expressions](#global-expressions)
|
||||
* [`{{branch}}`](#branch)
|
||||
* [`{{tag}}`](#tag)
|
||||
* [`{{sha}}`](#sha)
|
||||
* [`{{base_ref}}`](#base_ref)
|
||||
* [`{{is_default_branch}}`](#is_default_branch)
|
||||
* [`{{is_not_default_branch}}`](#is_not_default_branch)
|
||||
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
||||
* [Major version zero](#major-version-zero)
|
||||
* [JSON output object](#json-output-object)
|
||||
* [Overwrite labels and annotations](#overwrite-labels-and-annotations)
|
||||
* [Annotations](#annotations)
|
||||
* [Contributing](#contributing)
|
||||
- [About](#about)
|
||||
- [Key Differences from Original](#key-differences-from-original)
|
||||
- [What Was Removed](#what-was-removed)
|
||||
- [What Was Added](#what-was-added)
|
||||
- [Compatibility](#compatibility)
|
||||
- [Limitations](#limitations)
|
||||
- [Local Testing](#local-testing)
|
||||
- [Install act](#install-act)
|
||||
- [Run Tests](#run-tests)
|
||||
- [Usage](#usage)
|
||||
- [Basic](#basic)
|
||||
- [Semver](#semver)
|
||||
- [Bake definition](#bake-definition)
|
||||
- [Customizing](#customizing)
|
||||
- [inputs](#inputs)
|
||||
- [outputs](#outputs)
|
||||
- [environment variables](#environment-variables)
|
||||
- [`images` input](#images-input)
|
||||
- [`flavor` input](#flavor-input)
|
||||
- [`tags` input](#tags-input)
|
||||
- [`type=schedule`](#typeschedule)
|
||||
- [`type=semver`](#typesemver)
|
||||
- [`type=pep440`](#typepep440)
|
||||
- [`type=match`](#typematch)
|
||||
- [`type=edge`](#typeedge)
|
||||
- [`type=ref`](#typeref)
|
||||
- [`type=raw`](#typeraw)
|
||||
- [`type=sha`](#typesha)
|
||||
- [Notes](#notes)
|
||||
- [Image name and tag sanitization](#image-name-and-tag-sanitization)
|
||||
- [Latest tag](#latest-tag)
|
||||
- [`priority` attribute](#priority-attribute)
|
||||
- [Global expressions](#global-expressions)
|
||||
- [`{{branch}}`](#branch)
|
||||
- [`{{tag}}`](#tag)
|
||||
- [`{{sha}}`](#sha)
|
||||
- [`{{base_ref}}`](#base_ref)
|
||||
- [`{{is_default_branch}}`](#is_default_branch)
|
||||
- [`{{is_not_default_branch}}`](#is_not_default_branch)
|
||||
- [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||
- [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
||||
- [Major version zero](#major-version-zero)
|
||||
- [JSON output object](#json-output-object)
|
||||
- [Overwrite labels and annotations](#overwrite-labels-and-annotations)
|
||||
- [Annotations](#annotations)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -77,11 +165,11 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@ -131,11 +219,11 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: |
|
||||
name/app
|
||||
@ -210,7 +298,7 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: |
|
||||
name/app
|
||||
@ -295,7 +383,6 @@ The following inputs can be used as `step.with` keys:
|
||||
|
||||
| Name | Type | Description |
|
||||
|-------------------|--------|------------------------------------------------------------------------------|
|
||||
| `context` | String | Where to get context data. Allowed options are: `workflow` (default), `git`. |
|
||||
| `images` | List | List of Docker images to use as base name for tags |
|
||||
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
|
||||
| `flavor` | List | [Flavor](#flavor-input) to apply |
|
||||
@ -314,7 +401,7 @@ The following outputs are available:
|
||||
|-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `version` | String | Docker image version |
|
||||
| `tags` | String | Docker tags |
|
||||
| `tag-names` | String | Docker tag names without image base name |
|
||||
| `tag-names` | String | Docker tag names without the image base name |
|
||||
| `labels` | String | Docker labels |
|
||||
| `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
|
||||
| `json` | String | JSON output of tags and labels |
|
||||
@ -326,6 +413,7 @@ Alternatively, each output is also exported as an environment variable when `DOC
|
||||
|
||||
* `DOCKER_METADATA_OUTPUT_VERSION`
|
||||
* `DOCKER_METADATA_OUTPUT_TAGS`
|
||||
* `DOCKER_METADATA_OUTPUT_TAG_NAMES`
|
||||
* `DOCKER_METADATA_OUTPUT_LABELS`
|
||||
* `DOCKER_METADATA_OUTPUT_ANNOTATIONS`
|
||||
* `DOCKER_METADATA_OUTPUT_JSON`
|
||||
@ -351,20 +439,6 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
|
||||
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
|
||||
| `DOCKER_METADATA_SET_OUTPUT_ENV` | Bool | If `true`, sets each output as an environment variable (default `true`) |
|
||||
|
||||
## `context` input
|
||||
|
||||
`context` defines where to get context metadata:
|
||||
|
||||
```yaml
|
||||
# default
|
||||
context: workflow
|
||||
# or
|
||||
context: git
|
||||
```
|
||||
|
||||
* `workflow`: Get context metadata from the workflow (GitHub context). See https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
|
||||
* `git`: Get context metadata from the workflow and overrides some of them with current Git context, such as `ref` and `sha`.
|
||||
|
||||
## `images` input
|
||||
|
||||
`images` defines a list of Docker images to use as base name for [`tags`](#tags-input):
|
||||
@ -728,7 +802,7 @@ increase this length for larger repositories by setting the
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: |
|
||||
name/app
|
||||
@ -875,7 +949,7 @@ workflow run. Will be empty for a branch reference:
|
||||
> return the expected branch when the push tag event occurs. It's also
|
||||
> [not documented in GitHub docs](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push).
|
||||
> We keep it for backward compatibility, but it's **not recommended relying on it**.
|
||||
> More context in [#192](https://github.com/docker/metadata-action/pull/192#discussion_r854673012).
|
||||
> More context in [#192](https://github.com/LiquidLogicLabs/docker-metadata-action/pull/192#discussion_r854673012).
|
||||
|
||||
#### `{{is_default_branch}}`
|
||||
|
||||
@ -939,7 +1013,7 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
|
||||
```yaml
|
||||
-
|
||||
name: Docker meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
id: meta
|
||||
with:
|
||||
images: name/app
|
||||
@ -965,7 +1039,7 @@ this:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: name/app
|
||||
labels: |
|
||||
@ -987,7 +1061,7 @@ of the `metadata-action`:
|
||||
```yaml
|
||||
-
|
||||
name: Docker meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@ -1003,7 +1077,7 @@ The same can be done with the [`bake-action`](https://github.com/docker/bake-act
|
||||
```yaml
|
||||
-
|
||||
name: Docker meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@ -1032,7 +1106,7 @@ Please consult the documentation of your registry.
|
||||
```yaml
|
||||
-
|
||||
name: Docker meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: LiquidLogicLabs/docker-metadata-action@v0.1.0
|
||||
with:
|
||||
images: name/app
|
||||
env:
|
||||
|
||||
@ -2,20 +2,12 @@ import {afterEach, beforeEach, describe, expect, test, it, jest} from '@jest/glo
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {Context} from '@actions/github/lib/context';
|
||||
import {Git} from '@docker/actions-toolkit/lib/git';
|
||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
|
||||
import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
|
||||
|
||||
const toolkit = new Toolkit({githubToken: 'fake-github-token'});
|
||||
import * as gitModule from '../src/git';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.spyOn(GitHub, 'context', 'get').mockImplementation((): Context => {
|
||||
return new Context();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getInputs', () => {
|
||||
@ -36,17 +28,21 @@ describe('getInputs', () => {
|
||||
['images', 'moby/buildkit\nghcr.io/moby/mbuildkit'],
|
||||
]),
|
||||
{
|
||||
context: ContextSource.workflow,
|
||||
context: ContextSource.git,
|
||||
bakeTarget: 'docker-metadata-action',
|
||||
flavor: [],
|
||||
githubToken: '',
|
||||
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
|
||||
labels: [],
|
||||
annotations: [],
|
||||
sepLabels: '\n',
|
||||
sepTags: '\n',
|
||||
sepAnnotations: '\n',
|
||||
tags: [],
|
||||
tags: [
|
||||
'type=schedule',
|
||||
'type=ref,event=branch',
|
||||
'type=ref,event=tag',
|
||||
'type=ref,event=pr'
|
||||
],
|
||||
} as Inputs
|
||||
],
|
||||
[
|
||||
@ -59,17 +55,21 @@ describe('getInputs', () => {
|
||||
['sep-annotations', ',']
|
||||
]),
|
||||
{
|
||||
context: ContextSource.workflow,
|
||||
context: ContextSource.git,
|
||||
bakeTarget: 'metadata',
|
||||
flavor: [],
|
||||
githubToken: '',
|
||||
images: ['moby/buildkit'],
|
||||
labels: [],
|
||||
annotations: [],
|
||||
sepLabels: ',',
|
||||
sepTags: ',',
|
||||
sepAnnotations: ',',
|
||||
tags: [],
|
||||
tags: [
|
||||
'type=schedule',
|
||||
'type=ref,event=branch',
|
||||
'type=ref,event=tag',
|
||||
'type=ref,event=pr'
|
||||
],
|
||||
} as Inputs
|
||||
],
|
||||
[
|
||||
@ -78,17 +78,21 @@ describe('getInputs', () => {
|
||||
['images', 'moby/buildkit\n#comment\nghcr.io/moby/mbuildkit'],
|
||||
]),
|
||||
{
|
||||
context: ContextSource.workflow,
|
||||
context: ContextSource.git,
|
||||
bakeTarget: 'docker-metadata-action',
|
||||
flavor: [],
|
||||
githubToken: '',
|
||||
images: ['moby/buildkit', 'ghcr.io/moby/mbuildkit'],
|
||||
labels: [],
|
||||
annotations: [],
|
||||
sepLabels: '\n',
|
||||
sepTags: '\n',
|
||||
sepAnnotations: '\n',
|
||||
tags: [],
|
||||
tags: [
|
||||
'type=schedule',
|
||||
'type=ref,event=branch',
|
||||
'type=ref,event=tag',
|
||||
'type=ref,event=pr'
|
||||
],
|
||||
} as Inputs
|
||||
],
|
||||
])(
|
||||
@ -113,29 +117,43 @@ describe('getContext', () => {
|
||||
});
|
||||
afterEach(() => {
|
||||
process.env = originalEnv;
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('workflow', async () => {
|
||||
const context = await getContext(ContextSource.workflow, toolkit);
|
||||
it('should return git context', async () => {
|
||||
jest.spyOn(gitModule, 'getGitContext').mockImplementation(async () => {
|
||||
return {
|
||||
sha: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
|
||||
ref: process.env.GITHUB_REF || 'refs/heads/dev',
|
||||
commitDate: new Date('2024-11-13T13:42:28.000Z'),
|
||||
remoteUrl: 'https://github.com/test/repo.git',
|
||||
defaultBranch: 'master'
|
||||
};
|
||||
});
|
||||
|
||||
const context = await getContext(ContextSource.git);
|
||||
expect(context.ref).toEqual('refs/heads/dev');
|
||||
expect(context.sha).toEqual('5f3331d7f7044c18ca9f12c77d961c4d7cf3276a');
|
||||
expect(context.commitDate).toEqual(new Date('2024-11-13T13:42:28.000Z'));
|
||||
});
|
||||
|
||||
it('git', async () => {
|
||||
jest.spyOn(Git, 'context').mockImplementation((): Promise<Context> => {
|
||||
return Promise.resolve({
|
||||
ref: 'refs/heads/git-test',
|
||||
sha: 'git-test-sha'
|
||||
} as Context);
|
||||
it('should fall back to git commit date when workflow payload missing', async () => {
|
||||
jest.spyOn(gitModule, 'getGitContext').mockImplementation(async () => {
|
||||
return {
|
||||
sha: 'payload-sha',
|
||||
ref: 'refs/heads/workflow-branch',
|
||||
commitDate: new Date('2022-01-01T00:00:00.000Z'),
|
||||
remoteUrl: 'https://github.com/test/repo.git',
|
||||
defaultBranch: 'main'
|
||||
};
|
||||
});
|
||||
jest.spyOn(Git, 'commitDate').mockImplementation(async (): Promise<Date> => {
|
||||
return new Date('2023-01-01T13:42:28.000Z');
|
||||
});
|
||||
const context = await getContext(ContextSource.git, toolkit);
|
||||
expect(context.ref).toEqual('refs/heads/git-test');
|
||||
expect(context.sha).toEqual('git-test-sha');
|
||||
expect(context.commitDate).toEqual(new Date('2023-01-01T13:42:28.000Z'));
|
||||
process.env.GITHUB_SHA = 'payload-sha';
|
||||
process.env.GITHUB_REF = 'refs/heads/workflow-branch';
|
||||
delete process.env.GITHUB_EVENT_PATH;
|
||||
const context = await getContext(ContextSource.workflow);
|
||||
expect(context.ref).toEqual('refs/heads/workflow-branch');
|
||||
expect(context.sha).toEqual('payload-sha');
|
||||
expect(context.commitDate).toEqual(new Date('2022-01-01T00:00:00.000Z'));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
15
action.yml
15
action.yml
@ -1,16 +1,15 @@
|
||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||
name: 'Docker Metadata action'
|
||||
description: "GitHub Action to extract metadata (tags, labels) for Docker"
|
||||
author: 'docker'
|
||||
name: 'Docker Metadata action v2'
|
||||
description: "GitHub Action to extract metadata (tags, labels) for Docker using git commands (no dependency on GitHub API calls)"
|
||||
author: 'LiquidLogicLabs'
|
||||
branding:
|
||||
icon: 'anchor'
|
||||
color: 'blue'
|
||||
|
||||
inputs:
|
||||
context:
|
||||
description: 'Where to get context data. Allowed options are "workflow" (default), "git".'
|
||||
default: "workflow"
|
||||
required: true
|
||||
description: 'Source to derive metadata context (git|workflow, default git)'
|
||||
required: false
|
||||
images:
|
||||
description: 'List of Docker images to use as base name for tags'
|
||||
required: false
|
||||
@ -38,10 +37,6 @@ inputs:
|
||||
bake-target:
|
||||
description: 'Bake target name (default docker-metadata-action)'
|
||||
required: false
|
||||
github-token:
|
||||
description: 'GitHub Token as provided by secrets'
|
||||
default: ${{ github.token }}
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
version:
|
||||
|
||||
161
dist/index.js
generated
vendored
161
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
482
dist/licenses.txt
generated
vendored
482
dist/licenses.txt
generated
vendored
@ -1,11 +1,487 @@
|
||||
p-map
|
||||
@actions/core
|
||||
MIT
|
||||
MIT License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/exec
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@actions/io
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@babel/runtime-corejs3
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@fastify/busboy
|
||||
MIT
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
@kwsites/file-exists
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steve King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@kwsites/promise-deferred
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 kwsites
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
@renovate/pep440
|
||||
Apache-2.0
|
||||
This software is made available under the terms of *either* of the licenses
|
||||
found in LICENSE.APACHE or LICENSE.BSD. Contributions to this software is made
|
||||
under the terms of *both* these licenses.
|
||||
|
||||
|
||||
core-js-pure
|
||||
MIT
|
||||
Copyright (c) 2014-2025 Denis Pushkarev, 2025 CoreJS Company
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
csv-parse
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010 Adaltas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
debug
|
||||
MIT
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2018-2021 Josh Junon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the 'Software'), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
handlebars
|
||||
MIT
|
||||
Copyright (C) 2011-2019 by Yehuda Katz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
has-flag
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
moment
|
||||
MIT
|
||||
Copyright (c) JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
moment-timezone
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
ms
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Vercel, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
semver
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
simple-git
|
||||
MIT
|
||||
|
||||
source-map
|
||||
BSD-3-Clause
|
||||
|
||||
Copyright (c) 2009-2011, Mozilla Foundation and contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the Mozilla Foundation nor the names of project
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
supports-color
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
undici
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
xregexp
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2007-present Steven Levithan <http://xregexp.com/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
33
package.json
33
package.json
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "docker-metadata-action",
|
||||
"description": "GitHub Action to extract metadata (tags, labels) for Docker",
|
||||
"version": "0.1.1",
|
||||
"description": "GitHub Action to extract metadata (tags, labels) for Docker without GitHub API dependencies",
|
||||
"main": "src/main.ts",
|
||||
"scripts": {
|
||||
"build": "ncc build --source-map --minify --license licenses.txt",
|
||||
@ -10,11 +11,20 @@
|
||||
"eslint:fix": "eslint --fix .",
|
||||
"prettier": "prettier --check \"./**/*.ts\"",
|
||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"release": "standard-version --release-as patch && git push --follow-tags origin HEAD",
|
||||
"release:patch": "standard-version --release-as patch && git push --follow-tags origin HEAD",
|
||||
"release:minor": "standard-version --release-as minor && git push --follow-tags origin HEAD",
|
||||
"release:major": "standard-version --release-as major && git push --follow-tags origin HEAD",
|
||||
"release:pre-alpha": "standard-version --prerelease alpha && git push --follow-tags origin HEAD",
|
||||
"release:pre-beta": "standard-version --prerelease beta && git push --follow-tags origin HEAD",
|
||||
"release:pre-rc": "standard-version --prerelease rc && git push --follow-tags origin HEAD",
|
||||
"release:pre-dev": "standard-version --prerelease patch --prereleaseId dev && git push --follow-tags origin HEAD",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/docker/metadata-action.git"
|
||||
"url": "git+https://github.com/LiquidLogicLabs/docker-metadata-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
@ -28,16 +38,16 @@
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@docker/actions-toolkit": "^0.67.0",
|
||||
"@renovate/pep440": "^1.0.0",
|
||||
"csv-parse": "^6.1.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"moment": "^2.30.1",
|
||||
"moment-timezone": "^0.6.0",
|
||||
"semver": "^7.7.3"
|
||||
"semver": "^7.7.3",
|
||||
"simple-git": "^3.28.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/csv-parse": "^1.2.5",
|
||||
"@types/node": "^20.19.9",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
@ -50,8 +60,17 @@
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.6.2",
|
||||
"standard-version": "^9.5.0",
|
||||
"ts-jest": "^29.4.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.2"
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"standard-version": {
|
||||
"scripts": {
|
||||
"precommit": "git add CHANGELOG.md package.json"
|
||||
},
|
||||
"skip": {
|
||||
"tag": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
201
src/context.ts
201
src/context.ts
@ -1,12 +1,18 @@
|
||||
import * as core from '@actions/core';
|
||||
import {Context as GithubContext} from '@actions/github/lib/context';
|
||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||
import {Git} from '@docker/actions-toolkit/lib/git';
|
||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export interface Context extends GithubContext {
|
||||
import {getGitContext} from './git';
|
||||
|
||||
export interface Context {
|
||||
sha: string;
|
||||
ref: string;
|
||||
commitDate: Date;
|
||||
eventName: string;
|
||||
}
|
||||
|
||||
export enum ContextSource {
|
||||
workflow = 'workflow',
|
||||
git = 'git'
|
||||
}
|
||||
|
||||
export interface Inputs {
|
||||
@ -20,34 +26,68 @@ export interface Inputs {
|
||||
sepLabels: string;
|
||||
sepAnnotations: string;
|
||||
bakeTarget: string;
|
||||
githubToken: string;
|
||||
}
|
||||
|
||||
function getInputList(name: string, options?: {ignoreComma?: boolean; comment?: string}): string[] {
|
||||
const input = core.getInput(name);
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const items: string[] = [];
|
||||
for (const line of input.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (trimmed.length === 0) {
|
||||
continue;
|
||||
}
|
||||
if (options?.comment && trimmed.startsWith(options.comment)) {
|
||||
continue;
|
||||
}
|
||||
if (options?.ignoreComma) {
|
||||
items.push(trimmed);
|
||||
} else {
|
||||
items.push(
|
||||
...trimmed
|
||||
.split(',')
|
||||
.map(item => item.trim())
|
||||
.filter(item => item.length > 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
export function getInputs(): Inputs {
|
||||
const contextInput = (core.getInput('context') || ContextSource.git).toLowerCase();
|
||||
if (!Object.values(ContextSource).includes(contextInput as ContextSource)) {
|
||||
throw new Error(`Invalid context source: ${contextInput}`);
|
||||
}
|
||||
const tagsInput = getInputList('tags', {ignoreComma: true, comment: '#'});
|
||||
const defaultTags = [
|
||||
'type=schedule',
|
||||
'type=ref,event=branch',
|
||||
'type=ref,event=tag',
|
||||
'type=ref,event=pr'
|
||||
];
|
||||
|
||||
return {
|
||||
context: (core.getInput('context') || ContextSource.workflow) as ContextSource,
|
||||
images: Util.getInputList('images', {ignoreComma: true, comment: '#'}),
|
||||
tags: Util.getInputList('tags', {ignoreComma: true, comment: '#'}),
|
||||
flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#'}),
|
||||
labels: Util.getInputList('labels', {ignoreComma: true, comment: '#'}),
|
||||
annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#'}),
|
||||
context: contextInput as ContextSource,
|
||||
images: getInputList('images', {ignoreComma: true, comment: '#'}),
|
||||
tags: tagsInput.length > 0 ? tagsInput : defaultTags,
|
||||
flavor: getInputList('flavor', {ignoreComma: true, comment: '#'}),
|
||||
labels: getInputList('labels', {ignoreComma: true, comment: '#'}),
|
||||
annotations: getInputList('annotations', {ignoreComma: true, comment: '#'}),
|
||||
sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`,
|
||||
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
|
||||
sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,
|
||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
||||
githubToken: core.getInput('github-token')
|
||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`
|
||||
};
|
||||
}
|
||||
|
||||
export enum ContextSource {
|
||||
workflow = 'workflow',
|
||||
git = 'git'
|
||||
}
|
||||
|
||||
export async function getContext(source: ContextSource, toolkit: Toolkit): Promise<Context> {
|
||||
export async function getContext(source: ContextSource = ContextSource.git): Promise<Context> {
|
||||
switch (source) {
|
||||
case ContextSource.workflow:
|
||||
return await getContextFromWorkflow(toolkit);
|
||||
return await getContextFromWorkflow();
|
||||
case ContextSource.git:
|
||||
return await getContextFromGit();
|
||||
default:
|
||||
@ -55,82 +95,65 @@ export async function getContext(source: ContextSource, toolkit: Toolkit): Promi
|
||||
}
|
||||
}
|
||||
|
||||
async function getContextFromWorkflow(toolkit: Toolkit): Promise<Context> {
|
||||
const context = GitHub.context;
|
||||
|
||||
// Needs to override Git reference with pr ref instead of upstream branch ref
|
||||
// for pull_request_target event
|
||||
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
|
||||
if (/pull_request_target/.test(context.eventName)) {
|
||||
context.ref = `refs/pull/${context.payload.number}/merge`;
|
||||
}
|
||||
|
||||
// DOCKER_METADATA_PR_HEAD_SHA env var can be used to set associated head
|
||||
// SHA instead of commit SHA that triggered the workflow on pull request
|
||||
// event.
|
||||
if (/true/i.test(process.env.DOCKER_METADATA_PR_HEAD_SHA || '')) {
|
||||
if ((/pull_request/.test(context.eventName) || /pull_request_target/.test(context.eventName)) && context.payload?.pull_request?.head?.sha != undefined) {
|
||||
context.sha = context.payload.pull_request.head.sha;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
commitDate: await getCommitDateFromWorkflow(context.sha, toolkit),
|
||||
...context
|
||||
} as Context;
|
||||
}
|
||||
|
||||
async function getContextFromGit(): Promise<Context> {
|
||||
const ctx = await Git.context();
|
||||
const gitContext = await getGitContext();
|
||||
return {
|
||||
sha: gitContext.sha,
|
||||
ref: gitContext.ref,
|
||||
commitDate: gitContext.commitDate,
|
||||
eventName: process.env.GITHUB_EVENT_NAME || 'push'
|
||||
};
|
||||
}
|
||||
|
||||
async function getContextFromWorkflow(): Promise<Context> {
|
||||
const gitContext = await getGitContext();
|
||||
const payload = loadEventPayload();
|
||||
|
||||
const eventName = process.env.GITHUB_EVENT_NAME || 'workflow';
|
||||
const sha = process.env.GITHUB_SHA || gitContext.sha;
|
||||
const ref = process.env.GITHUB_REF || gitContext.ref;
|
||||
|
||||
const commitDate =
|
||||
resolveCommitDateFromPayload(payload, sha) ??
|
||||
gitContext.commitDate ??
|
||||
new Date();
|
||||
|
||||
return {
|
||||
commitDate: await Git.commitDate(ctx.sha),
|
||||
...ctx
|
||||
} as Context;
|
||||
sha,
|
||||
ref,
|
||||
commitDate,
|
||||
eventName
|
||||
};
|
||||
}
|
||||
|
||||
async function getCommitDateFromWorkflow(sha: string, toolkit: Toolkit): Promise<Date> {
|
||||
const event = GitHub.context.payload as unknown as {
|
||||
// branch push
|
||||
commits?: Array<{
|
||||
timestamp: string;
|
||||
// commit sha
|
||||
id: string;
|
||||
}>;
|
||||
// tags
|
||||
head_commit?: {
|
||||
timestamp: string;
|
||||
// commit sha
|
||||
id: string;
|
||||
};
|
||||
type WorkflowPayload = {
|
||||
commits?: Array<{id: string; timestamp: string}>;
|
||||
head_commit?: {id: string; timestamp: string};
|
||||
};
|
||||
|
||||
if (event.commits) {
|
||||
const commitDate = event.commits.find(x => x.id === sha)?.timestamp;
|
||||
if (commitDate) {
|
||||
return new Date(commitDate);
|
||||
function loadEventPayload(): WorkflowPayload {
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
||||
if (!eventPath) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (event.head_commit) {
|
||||
if (event.head_commit.id === sha) {
|
||||
return new Date(event.head_commit.timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
// fallback to github api for commit date
|
||||
try {
|
||||
const commit = await toolkit.github.octokit.rest.repos.getCommit({
|
||||
owner: GitHub.context.repo.owner,
|
||||
repo: GitHub.context.repo.repo,
|
||||
ref: sha
|
||||
});
|
||||
if (commit.data.commit.committer?.date) {
|
||||
return new Date(commit.data.commit.committer.date);
|
||||
}
|
||||
throw new Error('Committer date not found');
|
||||
const content = fs.readFileSync(eventPath, 'utf8');
|
||||
return JSON.parse(content);
|
||||
} catch (error) {
|
||||
core.debug(`Failed to get commit date from GitHub API: ${error.message}`);
|
||||
return new Date();
|
||||
core.debug(`Failed to read workflow event payload from ${eventPath}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCommitDateFromPayload(payload: WorkflowPayload, sha: string): Date | undefined {
|
||||
if (payload.commits) {
|
||||
const commit = payload.commits.find(item => item.id === sha);
|
||||
if (commit?.timestamp) {
|
||||
return new Date(commit.timestamp);
|
||||
}
|
||||
}
|
||||
if (payload.head_commit?.id === sha && payload.head_commit.timestamp) {
|
||||
return new Date(payload.head_commit.timestamp);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
116
src/git.ts
Normal file
116
src/git.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import simpleGit, {SimpleGit} from 'simple-git';
|
||||
|
||||
export interface GitContext {
|
||||
sha: string;
|
||||
ref: string;
|
||||
commitDate: Date;
|
||||
remoteUrl?: string;
|
||||
defaultBranch: string;
|
||||
}
|
||||
|
||||
export interface Repo {
|
||||
name: string;
|
||||
description?: string;
|
||||
url?: string;
|
||||
default_branch: string;
|
||||
license?: string;
|
||||
}
|
||||
|
||||
export async function getGitContext(): Promise<GitContext> {
|
||||
const git: SimpleGit = simpleGit();
|
||||
|
||||
try {
|
||||
const sha = await git.revparse(['HEAD']);
|
||||
|
||||
let ref = '';
|
||||
if (process.env.GITHUB_REF) {
|
||||
ref = process.env.GITHUB_REF;
|
||||
} else {
|
||||
try {
|
||||
ref = await git.revparse(['--symbolic-full-name', 'HEAD']);
|
||||
} catch {
|
||||
try {
|
||||
const tag = await git.raw(['describe', '--tags', '--exact-match']);
|
||||
if (tag) {
|
||||
ref = `refs/tags/${tag.trim()}`;
|
||||
}
|
||||
} catch {
|
||||
ref = 'HEAD';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const commitDateStr = await git.show(['-s', '--format=%cI', 'HEAD']);
|
||||
const commitDate = commitDateStr ? new Date(commitDateStr.trim()) : new Date();
|
||||
|
||||
let remoteUrl = '';
|
||||
try {
|
||||
const url = await git.remote(['get-url', 'origin']);
|
||||
remoteUrl = url ? url.trim() : '';
|
||||
} catch {
|
||||
// No remote configured
|
||||
}
|
||||
|
||||
let defaultBranch = '';
|
||||
try {
|
||||
const remoteHead = await git.revparse(['--symbolic-full-name', 'refs/remotes/origin/HEAD']);
|
||||
if (remoteHead) {
|
||||
defaultBranch = remoteHead.trim().replace(/^refs\/remotes\/origin\//, '');
|
||||
}
|
||||
} catch {
|
||||
try {
|
||||
const branches = await git.branch(['-r']);
|
||||
if (branches.all.includes('origin/main')) {
|
||||
defaultBranch = 'main';
|
||||
} else if (branches.all.includes('origin/master')) {
|
||||
defaultBranch = 'master';
|
||||
}
|
||||
} catch {
|
||||
defaultBranch = 'main';
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
sha: sha.trim(),
|
||||
ref: ref.trim(),
|
||||
commitDate,
|
||||
remoteUrl,
|
||||
defaultBranch
|
||||
};
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to get git context: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseRepoFromRemoteUrl(remoteUrl: string, defaultBranch: string): Repo {
|
||||
let name = '';
|
||||
let url = '';
|
||||
|
||||
if (remoteUrl) {
|
||||
const sshMatch = remoteUrl.match(/git@([^:]+):([^/]+)\/(.+?)(?:\.git)?$/);
|
||||
const httpsMatch = remoteUrl.match(/https?:\/\/([^/]+)\/([^/]+)\/(.+?)(?:\.git)?$/);
|
||||
|
||||
if (sshMatch) {
|
||||
const [, host, user, repo] = sshMatch;
|
||||
name = repo;
|
||||
url = `https://${host}/${user}/${repo}`;
|
||||
} else if (httpsMatch) {
|
||||
const [, host, user, repo] = httpsMatch;
|
||||
name = repo;
|
||||
url = `https://${host}/${user}/${repo}`;
|
||||
} else {
|
||||
const parts = remoteUrl.split('/');
|
||||
name = parts[parts.length - 1].replace(/\.git$/, '');
|
||||
url = remoteUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
url,
|
||||
default_branch: defaultBranch,
|
||||
description: '',
|
||||
license: ''
|
||||
};
|
||||
}
|
||||
|
||||
60
src/main.ts
60
src/main.ts
@ -1,39 +1,37 @@
|
||||
import * as fs from 'fs';
|
||||
import * as core from '@actions/core';
|
||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||
|
||||
import {getContext, getInputs, Inputs} from './context';
|
||||
import {getGitContext, parseRepoFromRemoteUrl, Repo} from './git';
|
||||
import {Meta, Version} from './meta';
|
||||
|
||||
actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
function setOutputAndEnv(name: string, value: string) {
|
||||
core.setOutput(name, value);
|
||||
core.exportVariable(`DOCKER_METADATA_OUTPUT_${name.replace(/\W/g, '_').toUpperCase()}`, value);
|
||||
}
|
||||
|
||||
function outputEnvEnabled(): boolean {
|
||||
if (process.env.DOCKER_METADATA_SET_OUTPUT_ENV) {
|
||||
return /true/i.test(process.env.DOCKER_METADATA_SET_OUTPUT_ENV);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const inputs: Inputs = getInputs();
|
||||
const toolkit = new Toolkit({githubToken: inputs.githubToken});
|
||||
const context = await getContext(inputs.context, toolkit);
|
||||
const repo = await toolkit.github.repoData();
|
||||
const context = await getContext(inputs.context);
|
||||
const gitContext = await getGitContext();
|
||||
const repo: Repo = parseRepoFromRemoteUrl(gitContext.remoteUrl || '', gitContext.defaultBranch);
|
||||
const setOutput = outputEnvEnabled() ? setOutputAndEnv : core.setOutput;
|
||||
|
||||
await core.group(`Context info`, async () => {
|
||||
core.info(`eventName: ${context.eventName}`);
|
||||
core.info(`sha: ${context.sha}`);
|
||||
core.info(`ref: ${context.ref}`);
|
||||
core.info(`workflow: ${context.workflow}`);
|
||||
core.info(`action: ${context.action}`);
|
||||
core.info(`actor: ${context.actor}`);
|
||||
core.info(`runNumber: ${context.runNumber}`);
|
||||
core.info(`runId: ${context.runId}`);
|
||||
core.info(`commitDate: ${context.commitDate}`);
|
||||
});
|
||||
|
||||
if (core.isDebug()) {
|
||||
await core.group(`Webhook payload`, async () => {
|
||||
core.info(JSON.stringify(context.payload, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
const meta: Meta = new Meta(inputs, context, repo);
|
||||
|
||||
const version: Version = meta.version;
|
||||
@ -46,8 +44,7 @@ actionsToolkit.run(
|
||||
}
|
||||
setOutput('version', version.main || '');
|
||||
|
||||
// Docker tags
|
||||
const tags = meta.getTags();
|
||||
const tags: Array<string> = meta.getTags();
|
||||
if (tags.length == 0) {
|
||||
core.warning('No Docker tag has been generated. Check tags input.');
|
||||
} else {
|
||||
@ -60,7 +57,6 @@ actionsToolkit.run(
|
||||
setOutput('tags', tags.join(inputs.sepTags));
|
||||
setOutput('tag-names', meta.getTags(true).join(inputs.sepTags));
|
||||
|
||||
// Docker labels
|
||||
const labels: Array<string> = meta.getLabels();
|
||||
await core.group(`Docker labels`, async () => {
|
||||
for (const label of labels) {
|
||||
@ -69,7 +65,6 @@ actionsToolkit.run(
|
||||
setOutput('labels', labels.join(inputs.sepLabels));
|
||||
});
|
||||
|
||||
// Annotations
|
||||
const annotationsRaw: Array<string> = meta.getAnnotations();
|
||||
const annotationsLevels = process.env.DOCKER_METADATA_ANNOTATIONS_LEVELS || 'manifest';
|
||||
await core.group(`Annotations`, async () => {
|
||||
@ -86,14 +81,12 @@ actionsToolkit.run(
|
||||
setOutput(`annotations`, annotations.join(inputs.sepAnnotations));
|
||||
});
|
||||
|
||||
// JSON
|
||||
const jsonOutput = meta.getJSON(annotationsLevels.split(','));
|
||||
await core.group(`JSON output`, async () => {
|
||||
core.info(JSON.stringify(jsonOutput, null, 2));
|
||||
setOutput('json', JSON.stringify(jsonOutput));
|
||||
});
|
||||
|
||||
// Bake files
|
||||
for (const kind of ['tags', 'labels', 'annotations:' + annotationsLevels]) {
|
||||
const outputName = kind.split(':')[0];
|
||||
const bakeFile: string = meta.getBakeFile(kind);
|
||||
@ -103,19 +96,10 @@ actionsToolkit.run(
|
||||
});
|
||||
}
|
||||
|
||||
// Bake file with tags and labels
|
||||
setOutput(`bake-file`, `${meta.getBakeFileTagsLabels()}`);
|
||||
} catch (error) {
|
||||
core.setFailed((error as Error).message);
|
||||
}
|
||||
);
|
||||
|
||||
function setOutputAndEnv(name: string, value: string) {
|
||||
core.setOutput(name, value);
|
||||
core.exportVariable(`DOCKER_METADATA_OUTPUT_${name.replace(/\W/g, '_').toUpperCase()}`, value);
|
||||
}
|
||||
|
||||
function outputEnvEnabled(): boolean {
|
||||
if (process.env.DOCKER_METADATA_SET_OUTPUT_ENV) {
|
||||
return Util.parseBool(process.env.DOCKER_METADATA_SET_OUTPUT_ENV);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
run();
|
||||
|
||||
85
src/meta.ts
85
src/meta.ts
@ -1,14 +1,14 @@
|
||||
import * as handlebars from 'handlebars';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import moment from 'moment-timezone';
|
||||
import * as pep440 from '@renovate/pep440';
|
||||
import * as semver from 'semver';
|
||||
import * as core from '@actions/core';
|
||||
import {Context as ToolkitContext} from '@docker/actions-toolkit/lib/context';
|
||||
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
|
||||
|
||||
import {Inputs, Context} from './context';
|
||||
import {Repo} from './git';
|
||||
import * as icl from './image';
|
||||
import * as tcl from './tag';
|
||||
import * as fcl from './flavor';
|
||||
@ -26,13 +26,13 @@ export class Meta {
|
||||
|
||||
private readonly inputs: Inputs;
|
||||
private readonly context: Context;
|
||||
private readonly repo: GitHubRepo;
|
||||
private readonly repo: Repo;
|
||||
private readonly images: icl.Image[];
|
||||
private readonly tags: tcl.Tag[];
|
||||
private readonly flavor: fcl.Flavor;
|
||||
private readonly date: Date;
|
||||
|
||||
constructor(inputs: Inputs, context: Context, repo: GitHubRepo) {
|
||||
constructor(inputs: Inputs, context: Context, repo: Repo) {
|
||||
this.inputs = inputs;
|
||||
this.context = context;
|
||||
this.repo = repo;
|
||||
@ -109,6 +109,7 @@ export class Meta {
|
||||
}
|
||||
|
||||
private procSchedule(version: Version, tag: tcl.Tag): Version {
|
||||
// Only process schedule tags when the event is actually a schedule event
|
||||
if (!/schedule/.test(this.context.eventName)) {
|
||||
return version;
|
||||
}
|
||||
@ -400,6 +401,7 @@ export class Meta {
|
||||
const context = this.context;
|
||||
const currentDate = this.date;
|
||||
const commitDate = this.context.commitDate;
|
||||
const repo = this.repo;
|
||||
return handlebars.compile(val)({
|
||||
branch: function () {
|
||||
if (!/^refs\/heads\//.test(context.ref)) {
|
||||
@ -417,14 +419,7 @@ export class Meta {
|
||||
return Meta.shortSha(context.sha);
|
||||
},
|
||||
base_ref: function () {
|
||||
if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {
|
||||
return context.payload.base_ref.replace(/^refs\/heads\//g, '');
|
||||
}
|
||||
// FIXME: keep this for backward compatibility even if doesn't always seem
|
||||
// to return the expected branch. See the comment below.
|
||||
if (/^refs\/pull\//.test(context.ref) && context.payload?.pull_request?.base?.ref != undefined) {
|
||||
return context.payload.pull_request.base.ref;
|
||||
}
|
||||
// In git-only mode, we don't have access to pull request base refs
|
||||
return '';
|
||||
},
|
||||
commit_date: function (format, options) {
|
||||
@ -443,25 +438,11 @@ export class Meta {
|
||||
},
|
||||
is_default_branch: function () {
|
||||
const branch = context.ref.replace(/^refs\/heads\//g, '');
|
||||
// TODO: "base_ref" is available in the push payload but doesn't always seem to
|
||||
// return the expected branch when the push tag event occurs. It's also not
|
||||
// documented in GitHub docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
|
||||
// more context: https://github.com/docker/metadata-action/pull/192#discussion_r854673012
|
||||
// if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {
|
||||
// branch = context.payload.base_ref.replace(/^refs\/heads\//g, '');
|
||||
// }
|
||||
if (branch == undefined || branch.length == 0) {
|
||||
return 'false';
|
||||
}
|
||||
if (context.payload?.repository?.default_branch == branch) {
|
||||
return 'true';
|
||||
}
|
||||
// following events always trigger for last commit on default branch
|
||||
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
|
||||
if (/create/.test(context.eventName) || /discussion/.test(context.eventName) || /issues/.test(context.eventName) || /schedule/.test(context.eventName)) {
|
||||
return 'true';
|
||||
}
|
||||
return 'false';
|
||||
// In git-only mode, we use the repo default_branch directly
|
||||
return branch === repo.default_branch ? 'true' : 'false';
|
||||
},
|
||||
is_not_default_branch: function () {
|
||||
return this.is_default_branch() === 'false' ? 'true' : 'false';
|
||||
@ -494,31 +475,15 @@ export class Meta {
|
||||
return images;
|
||||
}
|
||||
|
||||
public getTags(namesOnly?: boolean): Array<string> {
|
||||
public getTags(namesOnly = false): Array<string> {
|
||||
if (!this.version.main) {
|
||||
return [];
|
||||
}
|
||||
if (namesOnly) {
|
||||
return this.generateTags(this.version.main);
|
||||
}
|
||||
|
||||
const tags: Array<string> = [];
|
||||
const images = this.getImageNames();
|
||||
if (images.length > 0) {
|
||||
for (const imageName of images) {
|
||||
tags.push(...this.generateTags(this.version.main, imageName));
|
||||
}
|
||||
} else {
|
||||
tags.push(...this.generateTags(this.version.main));
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
private generateTags(version: string, imageName?: string): Array<string> {
|
||||
const tags: Array<string> = [];
|
||||
const generateTags = (imageName?: string): Array<string> => {
|
||||
const prefix = imageName ? `${imageName}:` : '';
|
||||
tags.push(`${prefix}${version}`);
|
||||
const tags: Array<string> = [];
|
||||
tags.push(`${prefix}${this.version.main}`);
|
||||
for (const partial of this.version.partial) {
|
||||
tags.push(`${prefix}${partial}`);
|
||||
}
|
||||
@ -527,6 +492,22 @@ export class Meta {
|
||||
tags.push(`${prefix}${Meta.sanitizeTag(latestTag)}`);
|
||||
}
|
||||
return tags;
|
||||
};
|
||||
|
||||
if (namesOnly) {
|
||||
return generateTags();
|
||||
}
|
||||
|
||||
const tags: Array<string> = [];
|
||||
const images = this.getImageNames();
|
||||
if (images.length > 0) {
|
||||
for (const imageName of images) {
|
||||
tags.push(...generateTags(imageName));
|
||||
}
|
||||
} else {
|
||||
tags.push(...generateTags());
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
public getLabels(): Array<string> {
|
||||
@ -541,12 +522,12 @@ export class Meta {
|
||||
const res: Array<string> = [
|
||||
`org.opencontainers.image.title=${this.repo.name || ''}`,
|
||||
`org.opencontainers.image.description=${this.repo.description || ''}`,
|
||||
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
|
||||
`org.opencontainers.image.source=${this.repo.html_url || ''}`,
|
||||
`org.opencontainers.image.url=${this.repo.url || ''}`,
|
||||
`org.opencontainers.image.source=${this.repo.url || ''}`,
|
||||
`org.opencontainers.image.version=${this.version.main || ''}`,
|
||||
`org.opencontainers.image.created=${this.date.toISOString()}`,
|
||||
`org.opencontainers.image.revision=${this.context.sha || ''}`,
|
||||
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
|
||||
`org.opencontainers.image.licenses=${this.repo.license || ''}`
|
||||
];
|
||||
extra.forEach(label => {
|
||||
res.push(this.setGlobalExp(label));
|
||||
@ -646,7 +627,7 @@ export class Meta {
|
||||
}
|
||||
|
||||
private generateBakeFile(dt, suffix?: string): string {
|
||||
const bakeFile = path.join(ToolkitContext.tmpDir(), `docker-metadata-action-bake${suffix ? `-${suffix}` : ''}.json`);
|
||||
const bakeFile = path.join(os.tmpdir(), `docker-metadata-action-bake${suffix ? `-${suffix}` : ''}.json`);
|
||||
fs.writeFileSync(bakeFile, JSON.stringify({target: {[this.inputs.bakeTarget]: dt}}, null, 2));
|
||||
return bakeFile;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user