-
Notifications
You must be signed in to change notification settings - Fork 584
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: CrazyMax <[email protected]>
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: 'Docker composite action' | ||
description: 'Set up Buildx and QEMU + Cache + Metadata + Build and push' | ||
|
||
inputs: | ||
images: | ||
description: "List of Docker image slugs (eg. name/app)" | ||
required: true | ||
context: | ||
description: "Build's context is the set of files located in the specified PATH or URL. (default Git context)" | ||
required: false | ||
file: | ||
description: "Path to the Dockerfile. (default {context}/Dockerfile)" | ||
required: false | ||
platforms: | ||
description: "List of target platforms (eg. linux/amd64)" | ||
required: false | ||
cachekey: | ||
description: "Cache key for local cache. (default buildx-{github.repository.name})" | ||
required: false | ||
default: "buildx-${{ github.repository.name}}" | ||
push: | ||
description: "Push image to the registry" | ||
required: false | ||
default: "true" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-${{ inputs.cachekey }}-cache | ||
key: ${{ runner.os }}-${{ inputs.cachekey }}-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ inputs.cachekey }}- | ||
- | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ inputs.images }} | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ${{ inputs.context }} | ||
file: ${{ inputs.file }} | ||
push: ${{ inputs.push }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: ${{ inputs.platforms }} | ||
cache-from: type=local,src=/tmp/.${{ inputs.cachekey }}-cache | ||
cache-to: type=local,dest=/tmp/.${{ inputs.cachekey }}-cache-new,mode=max | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
run: | | ||
rm -rf /tmp/.${{ inputs.cachekey }}-cache | ||
mv /tmp/.${{ inputs.cachekey }}-cache-new /tmp/.${{ inputs.cachekey }}-cache | ||
shell: bash |