Skip to content

Commit

Permalink
Merge pull request #26 from depot/feat/ephemeral-save
Browse files Browse the repository at this point in the history
feat: add option to save bake targets to ephemeral registry
  • Loading branch information
goller authored Mar 4, 2024
2 parents 5c5c746 + d9ac2b7 commit 513921d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ This action needs a Depot API token to communicate with your project's builders.

### Depot-specific inputs

| Name | Type | Description |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `project` | String | Depot [project](https://depot.dev/docs/core-concepts#projects) ID to route the image build to your projects builders (default: the `depot.json` file at the root of your repo) |
| `token` | String | You must authenticate with the Depot API to communicate with your projects builders ([see Authentication above](#authentication)) |
| `build-platform` | String | The platform to use for the build ( `linux/amd64` or `linux/arm64`) |
| `lint` | Bool | Lint dockerfiles and fail build if any issues are of `error` severity. (default `false`) |
| `lint-fail-on` | String | Severity of linter issue to cause the build to fail. (`error`, `warn`, `info`, `none`) |
| Name | Type | Description |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `project` | String | Depot [project](https://depot.dev/docs/core-concepts#projects) ID to route the image build to your projects builders (default: the `depot.json` file at the root of your repo) |
| `token` | String | You must authenticate with the Depot API to communicate with your projects builders ([see Authentication above](#authentication)) |
| `build-platform` | String | The platform to use for the build ( `linux/amd64` or `linux/arm64`) |
| `lint` | Bool | Lint dockerfiles and fail build if any issues are of `error` severity. (default `false`) |
| `lint-fail-on` | String | Severity of linter issue to cause the build to fail. (`error`, `warn`, `info`, `none`) |
| `save` | Boolean | Save the image to the Depot ephemeral registry (for use with the [depot/pull-action](https://github.com/depot/pull-action)) |

### General inputs

Expand All @@ -111,9 +112,12 @@ The following inputs can be used as `step.with` keys and match the inputs from [

## Outputs

| Name | Type | Description |
| ---------- | ---- | --------------------- |
| `metadata` | JSON | Build result metadata |
| Name | Type | Description |
| ------------ | ------ | --------------------- |
| `metadata` | JSON | Build result metadata |
| `project-id` | String | Depot Project ID |
| `build-id` | String | Depot Build ID |
| `targets` | Array | Saved Bake Targets |

## License

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ inputs:
description: 'Push is a shorthand for --set=*.output=type=registry'
required: false
default: 'false'
save:
description: 'Save the image to the Depot ephemeral registry'
required: false
default: 'false'
sbom:
description: 'SBOM is a shorthand for --set=*.attest=type=sbom'
required: false
Expand Down
18 changes: 17 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74336,6 +74336,7 @@ function getInputs() {
load: core.getBooleanInput("load"),
provenance: getProvenanceInput(),
push: core.getBooleanInput("push"),
save: core.getBooleanInput("save"),
sbom: core.getInput("sbom"),
sbomDir: core.getInput("sbom-dir"),
set: import_util.Util.getInputList("set", { ignoreComma: true, quote: false }),
Expand Down Expand Up @@ -76065,7 +76066,8 @@ async function bake(inputs) {
...flag("--project", inputs.project),
...flag("--build-platform", inputs.buildPlatform),
...flag("--lint", inputs.lint),
...flag("--lint-fail-on", inputs.lintFailOn)
...flag("--lint-fail-on", inputs.lintFailOn),
...flag("--save", inputs.save)
];
const args = [...bakeArgs, ...depotArgs, ...targets];
let token = inputs.token ?? process.env.DEPOT_TOKEN;
Expand Down Expand Up @@ -76149,8 +76151,22 @@ async function main() {
const metadata = getMetadata();
if (metadata) {
await core3.group(`Metadata`, async () => {
var _a, _b, _c;
core3.info(metadata);
core3.setOutput("metadata", metadata);
try {
const parsed = JSON.parse(metadata);
if ((_a = parsed == null ? void 0 : parsed["depot.build"]) == null ? void 0 : _a.buildID) {
core3.setOutput("build-id", parsed["depot.build"].buildID);
}
if ((_b = parsed == null ? void 0 : parsed["depot.build"]) == null ? void 0 : _b.projectID) {
core3.setOutput("project-id", parsed["depot.build"].projectID);
}
if ((_c = parsed == null ? void 0 : parsed["depot.build"]) == null ? void 0 : _c.targets) {
core3.setOutput("targets", parsed["depot.build"].targets);
}
} catch {
}
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Inputs {
load: boolean
provenance: string
push: boolean
save: boolean
sbom: string
sbomDir: string
set: string[]
Expand All @@ -39,6 +40,7 @@ export function getInputs(): Inputs {
load: core.getBooleanInput('load'),
provenance: getProvenanceInput(),
push: core.getBooleanInput('push'),
save: core.getBooleanInput('save'),
sbom: core.getInput('sbom'),
sbomDir: core.getInput('sbom-dir'),
set: Util.getInputList('set', {ignoreComma: true, quote: false}),
Expand Down
1 change: 1 addition & 0 deletions src/depot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function bake(inputs: Inputs) {
...flag('--build-platform', inputs.buildPlatform),
...flag('--lint', inputs.lint),
...flag('--lint-fail-on', inputs.lintFailOn),
...flag('--save', inputs.save),
]
const args = [...bakeArgs, ...depotArgs, ...targets]

Expand Down
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ async function main() {
await core.group(`Metadata`, async () => {
core.info(metadata)
core.setOutput('metadata', metadata)

try {
const parsed = JSON.parse(metadata)
if (parsed?.['depot.build']?.buildID) {
core.setOutput('build-id', parsed['depot.build'].buildID)
}
if (parsed?.['depot.build']?.projectID) {
core.setOutput('project-id', parsed['depot.build'].projectID)
}
if (parsed?.['depot.build']?.targets) {
core.setOutput('targets', parsed['depot.build'].targets)
}
} catch {}
})
}
}
Expand Down

0 comments on commit 513921d

Please sign in to comment.