Skip to content

dockerbakery/gradle-metadata-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Gradle Metadata Action for Docker Buildx Bake.

Usage

Bake definition

This action also handles a bake definition file that can be used with the Docker Bake action. You just have to declare an empty target named gradle-metadata-action and inherit from it.

// docker-bake.hcl
target "docker-metadata-action" {}
target "gradle-metadata-action" {}

target "build" {
  inherits = ["docker-metadata-action", "gradle-metadata-action"]
  context = "./"
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64",
    "linux/arm/v6",
    "linux/arm/v7",
    "linux/arm64",
    "linux/386"
  ]
}
name: ci

on:
  push:
    branches:
      - 'main'
    tags:
      - 'v*'
  pull_request:
    branches:
      - 'main'

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: |
            name/app
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=sha

      - name: Gradle meta
        id: gradle-meta
        uses: dockerbakery/gradle-metadata-action@v3

      - uses: docker/bake-action@v6
        with:
          files: |
            ./docker-bake.hcl
            cwd://${{ steps.meta.outputs.bake-file }}
            cwd://${{ steps.gradle-meta.outputs.bake-file }}
          targets: build

Content of ${{ steps.gradle-meta.outputs.bake-file }} file, generated by the Gradle Metadata Action:

{
  "group": {
    "default": {
      "targets": [
        "gradle-metadata-action"
      ]
    }
  },
  "target": {
    "gradle-metadata-action": {
      "args": {
        "GRADLE_VERSION": "7.6",
        "GRADLE_PROJECT_NAME": "example-project",
        "GRADLE_PROJECT_DESCRIPTION": "example-project",
        "GRADLE_PROJECT_GROUP": "com.example",
        "GRADLE_PROJECT_PROFILE": "dev",
        "GRADLE_PROJECT_VERSION": "1.0.0-SNAPSHOT",
        "GRADLE_PROJECT_PROFILE": "production",
        "GRADLE_BUILD_ARTIFACT_ID": "example-project-1.0.0-SNAPSHOT",
        "GRADLE_BUILD_ARTIFACT": "example-project-1.0.0-SNAPSHOT.jar",
        "GRADLE_TARGET_COMPATIBILITY": "11",
        "GRADLE_SOURCE_COMPATIBILITY": "11",
        "JAVA_VENDOR": "AdoptOpenJDK",
        "JAVA_VERSION": "11.0.11",
      }
    }
  }
}

Input

Following inputs can be used as step.with keys

Name Description
context Where to get context data. Allowed options are: workflow (default "current directory).
version Set the version of the Gradle project (override the version property)

Output

Following outputs can be used as steps.<step_id>.outputs keys

Name Description
name Name of the Gradle project.
version Version of the Gradle project.
source-compatibility Source compatibility of the Gradle project.
target-compatibility Target compatibility of the Gradle project.
bake-file Path to the generated bake file.

Resources