|
1 |
| -# buildkit-build-push-action |
2 |
| -Buildkit - Build & Push Action |
| 1 | +# Buildkit - Build & Push Action |
| 2 | + |
| 3 | +A minimally opinionated GitHub action for BuildKit's [`buildctl`](https://github.com/moby/buildkit/blob/master/docs/reference/buildctl.md). |
| 4 | + |
| 5 | +# Requirements |
| 6 | + |
| 7 | +- BuildKit's `buildctl` ~=v0.15.1 has to be available in the path of the action runner, e.g. [act-buildkit-runner](https://github.com/omniproc/act-buildkit-runner). |
| 8 | + |
| 9 | +# Inputs |
| 10 | + |
| 11 | +| Name | Required | Type | Description | Example | |
| 12 | +| --------------------------- | -------- | ------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | |
| 13 | +| `debug` | No | Boolean | Enable debug output in logs | `false` | |
| 14 | +| `addr` | Yes | String | Buildkitd address | `tcp://buildkitd:1234` | |
| 15 | +| `log_format` | No | String | Log formatter: json or text | `text` | |
| 16 | +| `tlsdir` | No | String | Directory containing CA certificate, client certificate, and client key | `/path/to/tls-data` | |
| 17 | +| `output` | Yes | String | Define exports for build result. `name=` may be left out if `tags` are provided. | `type=image,name=ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:stable,push=true` | |
| 18 | +| `progress` | No | String | Set type of progress (auto, plain, tty, rawjson) | `auto` | |
| 19 | +| `local` | Yes | List | Allow build access to the local directory | <pre> local: \| <br> context=.<br> dockerfile=.<br></pre> | |
| 20 | +| `frontend` | No | String | Define frontend used for build | `dockerfile.v0` | |
| 21 | +| `opt` | No | List | Define custom options for frontend | <pre> opt: \| <br> filename=Dockerfile<br> platform=linux/amd64<br></pre> | |
| 22 | +| `no_cache` | No | Boolean | Disable cache for all the vertices | `true` | |
| 23 | +| `export-cache` | No | String | Export build cache | `type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max,push=true` | |
| 24 | +| `import-cache` | No | String | Import build cache | `type=registry,ref=ghcr.io/${{ github.repository }}:buildcache` | |
| 25 | +| `secret` | No | List | Secret value exposed to the build | <pre> secret: \| <br> id=foo,src=/path/to/foo<br> id=bar,src=/path/to/bar<br></pre> | |
| 26 | +| `registry-auth-tls-context` | No | String | Overwrite TLS configuration when authenticating with registries | `host=https://myserver:2376,insecure=false,ca=/path/to/my/ca.crt,cert=/path/to/my/cert.crt,key=/path/to/my/key.crt` | |
| 27 | +| `tags` | Yes | List | Image tags extending the `name`s used in the `output` input | <pre> tags: \| <br> {{ github.repository }}:sha-ca56cb6<br> {{ github.repository }}:latest<br></pre> | |
| 28 | +| `dryrun` | No | Boolean | Only print the resulting `buildctl` command but do not actually execute it | `false` | |
| 29 | + |
| 30 | +# Example usage |
| 31 | + |
| 32 | +When pushing the built image make sure to have authenticated with the registry using e.g. [docker/login-action](https://github.com/docker/login-action) in a step before. |
| 33 | + |
| 34 | +```yaml |
| 35 | +name: Example |
| 36 | +on: |
| 37 | + push |
| 38 | +jobs: |
| 39 | + build: |
| 40 | + runs-on: ubuntu-22.04 |
| 41 | + container: |
| 42 | + image: ghcr.io/omniproc/act-buildkit-runner:1.0.0 |
| 43 | + steps: |
| 44 | + - name: oci metadata |
| 45 | + id: meta |
| 46 | + uses: docker/metadata-action@v5 |
| 47 | + with: |
| 48 | + images: | |
| 49 | + ghcr.io/${{ github.repository }} |
| 50 | + tags: | |
| 51 | + type=sha,event=branch |
| 52 | + type=raw,value=latest,enable={{is_default_branch}} |
| 53 | + - name: oci build |
| 54 | + |
| 55 | + with: |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + addr: 'tcp://buildkitd:1234' |
| 58 | + output: 'type=image,push=false' |
| 59 | +``` |
| 60 | +
|
| 61 | +# Development |
| 62 | +
|
| 63 | +```bash |
| 64 | +# When a new version of this action is ready, use ncc to bundle it. |
| 65 | +ncc build src/index.js --license licenses.txt |
| 66 | +# Add everything to Git and tag the commit. The tag will be used as action version. |
| 67 | +git add . |
| 68 | +git commit -m "Release vX.x" |
| 69 | +git tag -a -m "Release vX.x" vX.x |
| 70 | +git push --follow-tags |
| 71 | +``` |
0 commit comments