Skip to content

Commit

Permalink
Merge pull request #77 from crazy-max/rename-bake-target
Browse files Browse the repository at this point in the history
Rename bake target
  • Loading branch information
crazy-max committed May 10, 2021
2 parents c8b87a0 + ed01528 commit 8d3d13f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
Binary file modified .github/metadata-action.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -152,14 +152,14 @@ jobs:

This action also handles a bake definition file that can be used with the
[Docker Bake action](https://github.com/docker/bake-action). You just have to declare an empty target named
`ghaction-docker-meta` and inherit from it.
`docker-metadata-action` and inherit from it.

```hcl
// docker-bake.hcl
target "ghaction-docker-meta" {}
target "docker-metadata-action" {}
target "build" {
inherits = ["ghaction-docker-meta"]
inherits = ["docker-metadata-action"]
context = "./"
dockerfile = "Dockerfile"
platforms = ["linux/amd64", "linux/arm/v6", "linux/arm/v7", "linux/arm64", "linux/386", "linux/ppc64le"]
Expand Down Expand Up @@ -210,7 +210,7 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `
```json
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"name/app:1.2.3",
"name/app:1.2",
Expand Down Expand Up @@ -263,7 +263,7 @@ Following inputs can be used as `step.with` keys
| `labels` | List | List of custom labels |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `bake-target` | String | Bake target name (default `ghaction-docker-meta`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
### outputs
Expand Down
2 changes: 1 addition & 1 deletion __tests__/context.test.ts
Expand Up @@ -5,7 +5,7 @@ import * as path from 'path';
import * as context from '../src/context';

jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
const tmpDir = path.join('/tmp/.ghaction-docker-meta-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join('/tmp/.docker-metadata-action-jest').split(path.sep).join(path.posix.sep);
if (!fs.existsSync(tmpDir)) {
fs.mkdirSync(tmpDir, {recursive: true});
}
Expand Down
12 changes: 6 additions & 6 deletions __tests__/meta.test.ts
Expand Up @@ -2382,7 +2382,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"user/app:dev",
"user/app:my",
Expand Down Expand Up @@ -2419,7 +2419,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"user/app:dev",
"user/app:my",
Expand Down Expand Up @@ -2500,7 +2500,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"user/app:20200110",
"user/app:my",
Expand Down Expand Up @@ -2541,7 +2541,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"org/app:1.1.1",
"org/app:1.1",
Expand Down Expand Up @@ -2589,7 +2589,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"org/app:my",
"org/app:custom",
Expand Down Expand Up @@ -2630,7 +2630,7 @@ describe('bake', () => {
} as Inputs,
{
"target": {
"ghaction-docker-meta": {
"docker-metadata-action": {
"tags": [
"org/app:v1.1.1",
"org/app:latest"
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -26,7 +26,7 @@ inputs:
description: 'Separator to use for labels output (default \n)'
required: false
bake-target:
description: 'Bake target name (default ghaction-docker-meta)'
description: 'Bake target name (default docker-metadata-action)'
required: false
github-token:
description: 'GitHub Token as provided by secrets'
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/context.ts
Expand Up @@ -20,7 +20,7 @@ export interface Inputs {

export function tmpDir(): string {
if (!_tmpDir) {
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-docker-meta-')).split(path.sep).join(path.posix.sep);
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-')).split(path.sep).join(path.posix.sep);
}
return _tmpDir;
}
Expand All @@ -33,7 +33,7 @@ export function getInputs(): Inputs {
labels: getInputList('labels', true),
sepTags: core.getInput('sep-tags') || `\n`,
sepLabels: core.getInput('sep-labels') || `\n`,
bakeTarget: core.getInput('bake-target') || `ghaction-docker-meta`,
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
githubToken: core.getInput('github-token')
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta.ts
Expand Up @@ -322,7 +322,7 @@ export class Meta {
jsonLabels[matches[1]] = matches[2];
}

const bakeFile = path.join(tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
const bakeFile = path.join(tmpDir(), 'docker-metadata-action-bake.json').split(path.sep).join(path.posix.sep);
fs.writeFileSync(
bakeFile,
JSON.stringify(
Expand Down
4 changes: 2 additions & 2 deletions test/docker-bake.hcl
@@ -1,4 +1,4 @@
target "ghaction-docker-meta" {}
target "docker-metadata-action" {}

group "default" {
targets = ["db", "app"]
Expand All @@ -14,7 +14,7 @@ target "db" {
}

target "app" {
inherits = ["ghaction-docker-meta"]
inherits = ["docker-metadata-action"]
context = "./test"
dockerfile = "Dockerfile"
args = {
Expand Down

0 comments on commit 8d3d13f

Please sign in to comment.