mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-06 00:35:53 -05:00
Add Git context example
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
1c3fedb652
commit
5003e0df3d
1 changed files with 67 additions and 6 deletions
73
README.md
73
README.md
|
@ -7,6 +7,7 @@ ___
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Quick start](#quick-start)
|
* [Quick start](#quick-start)
|
||||||
* [Bake](#bake)
|
* [Bake](#bake)
|
||||||
|
* [Git context](#git-context)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
|
@ -47,8 +48,6 @@ jobs:
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
|
||||||
install: true
|
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
|
@ -70,7 +69,7 @@ jobs:
|
||||||
### Bake
|
### Bake
|
||||||
|
|
||||||
[Buildx bake](https://github.com/docker/buildx#buildx-bake-options-target) is also available with this action through
|
[Buildx bake](https://github.com/docker/buildx#buildx-bake-options-target) is also available with this action through
|
||||||
the [`bake` inputs](#inputs).
|
the [`bake` inputs](#inputs):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
@ -83,7 +82,7 @@ on:
|
||||||
tags:
|
tags:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
buildx:
|
bake:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
|
@ -98,8 +97,6 @@ jobs:
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
|
||||||
install: true
|
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
|
@ -120,6 +117,58 @@ jobs:
|
||||||
release
|
release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Git context
|
||||||
|
|
||||||
|
You can build from Git directly without [`actions/checkout`](https://github.com/actions/checkout/) action,
|
||||||
|
even in private repositories if your `context` is a valid Git url:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: master
|
||||||
|
push:
|
||||||
|
branches: master
|
||||||
|
tags:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
git-context:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
with:
|
||||||
|
platforms: all
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: ./
|
||||||
|
env:
|
||||||
|
GIT_AUTH_TOKEN: ${{ github.token }}
|
||||||
|
GIT_REF: ${{ github.ref }}
|
||||||
|
with:
|
||||||
|
context: ${{ github.repositoryUrl }}
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
name/app:latest
|
||||||
|
name/app:1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
|
@ -156,6 +205,18 @@ Following outputs are available
|
||||||
|---------------|---------|---------------------------------------|
|
|---------------|---------|---------------------------------------|
|
||||||
| `digest` | String | Image content-addressable identifier also called a digest |
|
| `digest` | String | Image content-addressable identifier also called a digest |
|
||||||
|
|
||||||
|
### environment variables
|
||||||
|
|
||||||
|
Following environment variables can be used as `step.env` keys
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
|--------------------------|---------------------------------------|
|
||||||
|
| `GIT_AUTH_HEADER`**¹** | Raw authorization header to authenticate against git repository |
|
||||||
|
| `GIT_AUTH_TOKEN`**¹** | `x-access-token` basic auth to authenticate against git repository |
|
||||||
|
| `GIT_REF`**¹** | Git refrerence to use against git repository |
|
||||||
|
|
||||||
|
> **¹** Only used if `input.context` is a valid git uri.
|
||||||
|
|
||||||
## Limitation
|
## Limitation
|
||||||
|
|
||||||
This action is only available for Linux [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources).
|
This action is only available for Linux [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources).
|
||||||
|
|
Loading…
Reference in a new issue