2020-08-15 22:36:41 +00:00
|
|
|
name: ci
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-09-11 23:44:53 +00:00
|
|
|
branches: master
|
|
|
|
tags:
|
|
|
|
- 'v*.*.*'
|
2020-08-15 22:36:41 +00:00
|
|
|
pull_request:
|
2020-09-11 23:44:53 +00:00
|
|
|
branches: master
|
2020-08-15 22:36:41 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-09-02 08:07:11 +00:00
|
|
|
git-context:
|
2020-08-17 20:18:15 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-08-23 01:31:38 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
buildx-version:
|
|
|
|
- latest
|
2020-09-05 03:18:15 +00:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-17 20:18:15 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-08 21:16:37 +00:00
|
|
|
uses: actions/checkout@v2.3.2
|
2020-08-17 20:18:15 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-17 20:18:15 +00:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-17 20:18:15 +00:00
|
|
|
with:
|
2020-08-23 01:31:38 +00:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-03 16:17:27 +00:00
|
|
|
driver-opts: network=host
|
2020-08-17 20:18:15 +00:00
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
file: ./test/Dockerfile
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-09-02 08:07:11 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2020-08-17 20:18:15 +00:00
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-09-02 08:07:11 +00:00
|
|
|
secrets: |
|
|
|
|
GIT_AUTH_TOKEN=${{ github.token }}
|
2020-08-17 20:18:15 +00:00
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
|
2020-09-02 08:07:11 +00:00
|
|
|
path-context:
|
2020-08-15 22:36:41 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2020-08-23 01:31:38 +00:00
|
|
|
buildx-version:
|
|
|
|
- ""
|
|
|
|
- latest
|
2020-09-05 03:18:15 +00:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-15 22:36:41 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-08 21:16:37 +00:00
|
|
|
uses: actions/checkout@v2.3.2
|
2020-08-15 22:36:41 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-15 22:36:41 +00:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-17 00:33:38 +00:00
|
|
|
with:
|
2020-08-23 01:31:38 +00:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-03 16:17:27 +00:00
|
|
|
driver-opts: network=host
|
2020-08-15 22:36:41 +00:00
|
|
|
-
|
|
|
|
name: Build and push
|
2020-08-23 02:07:29 +00:00
|
|
|
id: docker_build
|
2020-08-15 22:36:41 +00:00
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
2020-09-02 08:07:11 +00:00
|
|
|
file: ./test/Dockerfile
|
2020-08-16 01:21:48 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-08-17 00:33:38 +00:00
|
|
|
push: true
|
2020-08-15 22:36:41 +00:00
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-08-17 00:42:46 +00:00
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
2020-08-23 02:06:55 +00:00
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
2020-08-15 22:36:41 +00:00
|
|
|
-
|
|
|
|
name: Dump context
|
2020-08-16 15:18:08 +00:00
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
|
2020-09-02 08:07:11 +00:00
|
|
|
multi:
|
2020-08-29 14:10:05 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-02 08:07:11 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
buildx-version:
|
|
|
|
- ""
|
|
|
|
- latest
|
|
|
|
dockerfile:
|
|
|
|
- multi
|
|
|
|
- multi-sudo
|
2020-09-05 03:18:15 +00:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-29 14:10:05 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-08 21:16:37 +00:00
|
|
|
uses: actions/checkout@v2.3.2
|
2020-08-29 14:10:05 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-29 14:10:05 +00:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-29 14:10:05 +00:00
|
|
|
with:
|
2020-09-02 08:07:11 +00:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-03 16:17:27 +00:00
|
|
|
driver-opts: network=host
|
2020-08-29 14:10:05 +00:00
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
2020-09-02 08:07:11 +00:00
|
|
|
file: ./test/Dockerfile-${{ matrix.dockerfile }}
|
2020-08-29 14:10:05 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
|
2020-09-02 08:07:11 +00:00
|
|
|
github-cache:
|
2020-08-16 15:55:47 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-05 03:18:15 +00:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-16 15:55:47 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-08 21:16:37 +00:00
|
|
|
uses: actions/checkout@v2.3.2
|
2020-08-16 15:55:47 +00:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-16 15:55:47 +00:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-08 22:32:40 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-16 17:22:14 +00:00
|
|
|
with:
|
2020-09-03 16:17:27 +00:00
|
|
|
driver-opts: network=host
|
2020-09-02 08:07:11 +00:00
|
|
|
-
|
|
|
|
name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
2020-08-16 15:55:47 +00:00
|
|
|
-
|
|
|
|
name: Build and push
|
2020-08-23 02:07:29 +00:00
|
|
|
id: docker_build
|
2020-08-16 15:55:47 +00:00
|
|
|
uses: ./
|
|
|
|
with:
|
2020-09-02 08:07:11 +00:00
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile-multi-golang
|
2020-08-16 15:55:47 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-08-16 20:38:03 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2020-08-17 00:33:38 +00:00
|
|
|
push: true
|
2020-08-16 15:55:47 +00:00
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-09-02 08:07:11 +00:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
2020-08-17 00:42:46 +00:00
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
2020-08-23 02:06:55 +00:00
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
2020-09-02 08:07:11 +00:00
|
|
|
-
|
|
|
|
name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
2020-08-16 15:55:47 +00:00
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
2020-09-11 23:44:53 +00:00
|
|
|
|
|
|
|
tags-labels:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v2.3.2
|
|
|
|
-
|
|
|
|
name: Prepare
|
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=localhost:5000/name/app
|
|
|
|
VERSION=noop
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
|
|
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
|
|
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
|
|
|
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
|
|
|
|
VERSION=edge
|
|
|
|
fi
|
|
|
|
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
|
|
|
VERSION=pr-${{ github.event.number }}
|
|
|
|
fi
|
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
|
|
if [ "${{ github.event_name }}" != "pull_request" ]; then
|
|
|
|
TAGS="${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
|
|
|
|
fi
|
|
|
|
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
|
|
MINOR=${VERSION%.*}
|
|
|
|
MAJOR=${MINOR%.*}
|
|
|
|
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
|
|
|
|
fi
|
|
|
|
echo ::set-output name=version::${VERSION}
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
|
|
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
-
|
|
|
|
name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
driver-opts: network=host
|
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
|
|
org.opencontainers.image.source=${{ github.repositoryUrl }}
|
|
|
|
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
|
|
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
|
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:${{ steps.prep.outputs.version }}
|
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|