2020-08-16 06:36:41 +08:00
|
|
|
name: ci
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-09-13 02:53:25 +08:00
|
|
|
branches:
|
|
|
|
- master
|
2020-08-16 06:36:41 +08:00
|
|
|
pull_request:
|
2020-09-13 02:53:25 +08:00
|
|
|
branches:
|
|
|
|
- master
|
2020-08-16 06:36:41 +08:00
|
|
|
|
|
|
|
jobs:
|
2020-09-02 16:07:11 +08:00
|
|
|
git-context:
|
2020-08-18 04:18:15 +08:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-23 02:53:40 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-24 14:25:40 +08:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-10-04 04:44:16 +08:00
|
|
|
with:
|
|
|
|
path: action
|
2020-09-23 02:53:40 +08:00
|
|
|
-
|
|
|
|
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
|
|
|
|
driver-opts: network=host
|
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
2020-10-04 04:44:16 +08:00
|
|
|
uses: ./action
|
2020-09-23 02:53:40 +08:00
|
|
|
with:
|
|
|
|
file: ./test/Dockerfile
|
|
|
|
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
|
|
|
|
|
|
|
|
git-context-secret:
|
|
|
|
runs-on: ubuntu-latest
|
2020-09-05 11:18:15 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-18 04:18:15 +08:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-24 14:25:40 +08:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-10-04 04:44:16 +08:00
|
|
|
with:
|
|
|
|
path: action
|
2020-08-18 04:18:15 +08:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-18 04:18:15 +08:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-18 04:18:15 +08:00
|
|
|
with:
|
2020-08-23 09:31:38 +08:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-04 00:17:27 +08:00
|
|
|
driver-opts: network=host
|
2020-08-18 04:18:15 +08:00
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
2020-10-04 04:44:16 +08:00
|
|
|
uses: ./action
|
2020-08-18 04:18:15 +08:00
|
|
|
with:
|
|
|
|
file: ./test/Dockerfile
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-09-02 16:07:11 +08:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2020-08-18 04:18:15 +08:00
|
|
|
push: true
|
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-09-02 16:07:11 +08:00
|
|
|
secrets: |
|
2020-09-23 17:04:40 +08:00
|
|
|
GIT_AUTH_TOKEN=${{ github.token }}
|
2020-08-18 04:18:15 +08: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 16:07:11 +08:00
|
|
|
path-context:
|
2020-08-16 06:36:41 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2020-08-23 09:31:38 +08:00
|
|
|
buildx-version:
|
|
|
|
- ""
|
|
|
|
- latest
|
2020-09-05 11:18:15 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-16 06:36:41 +08:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-24 14:25:40 +08:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-08-16 06:36:41 +08:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-16 06:36:41 +08:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-17 08:33:38 +08:00
|
|
|
with:
|
2020-08-23 09:31:38 +08:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-04 00:17:27 +08:00
|
|
|
driver-opts: network=host
|
2020-08-16 06:36:41 +08:00
|
|
|
-
|
|
|
|
name: Build and push
|
2020-08-23 10:07:29 +08:00
|
|
|
id: docker_build
|
2020-08-16 06:36:41 +08:00
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
2020-09-02 16:07:11 +08:00
|
|
|
file: ./test/Dockerfile
|
2020-08-16 09:21:48 +08:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-08-17 08:33:38 +08:00
|
|
|
push: true
|
2020-08-16 06:36:41 +08:00
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-08-17 08:42:46 +08:00
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
2020-08-23 10:06:55 +08:00
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
2020-08-16 06:36:41 +08:00
|
|
|
-
|
|
|
|
name: Dump context
|
2020-08-16 23:18:08 +08:00
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
|
2020-09-02 16:07:11 +08:00
|
|
|
multi:
|
2020-08-29 22:10:05 +08:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-02 16:07:11 +08:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
buildx-version:
|
|
|
|
- ""
|
|
|
|
- latest
|
|
|
|
dockerfile:
|
|
|
|
- multi
|
|
|
|
- multi-sudo
|
2020-09-05 11:18:15 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-29 22:10:05 +08:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-24 14:25:40 +08:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-08-29 22:10:05 +08:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-29 22:10:05 +08:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-29 22:10:05 +08:00
|
|
|
with:
|
2020-09-02 16:07:11 +08:00
|
|
|
version: ${{ matrix.buildx-version }}
|
2020-09-04 00:17:27 +08:00
|
|
|
driver-opts: network=host
|
2020-08-29 22:10:05 +08:00
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
2020-09-02 16:07:11 +08:00
|
|
|
file: ./test/Dockerfile-${{ matrix.dockerfile }}
|
2020-08-29 22:10:05 +08: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-10-04 06:01:14 +08:00
|
|
|
registry-cache:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v2.3.3
|
|
|
|
-
|
|
|
|
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:
|
|
|
|
driver-opts: network=host
|
|
|
|
-
|
|
|
|
name: Build and push (1)
|
|
|
|
id: docker_build
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile-multi
|
|
|
|
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
|
|
|
|
cache-from: type=registry,ref=localhost:5000/name/app:cache
|
|
|
|
cache-to: type=registry,ref=localhost:5000/name/app:cache
|
|
|
|
-
|
|
|
|
name: Inspect (1)
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
|
|
|
-
|
|
|
|
name: Inspect cache (1)
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:cache
|
|
|
|
-
|
|
|
|
name: Image digest (1)
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
-
|
|
|
|
name: Prune
|
|
|
|
run: |
|
|
|
|
docker buildx prune -a -f --verbose
|
|
|
|
-
|
|
|
|
name: Build and push (2)
|
|
|
|
id: docker_build2
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile-multi
|
|
|
|
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
|
|
|
|
cache-from: type=registry,ref=localhost:5000/name/app:cache
|
|
|
|
cache-to: type=registry,ref=localhost:5000/name/app:cache
|
|
|
|
-
|
|
|
|
name: Inspect (2)
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
|
|
|
-
|
|
|
|
name: Inspect cache (2)
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:cache
|
|
|
|
-
|
|
|
|
name: Image digest (2)
|
|
|
|
run: echo ${{ steps.docker_build2.outputs.digest }}
|
|
|
|
-
|
|
|
|
name: Check digests
|
|
|
|
run: |
|
|
|
|
echo Compare "${{ steps.docker_build.outputs.digest }}" with "${{ steps.docker_build2.outputs.digest }}"
|
|
|
|
if [ "${{ steps.docker_build.outputs.digest }}" != "${{ steps.docker_build2.outputs.digest }}" ]; then
|
|
|
|
echo "::error::Digests should be identical"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|
|
|
|
|
2020-10-04 04:44:16 +08:00
|
|
|
github-cache-first:
|
|
|
|
runs-on: ubuntu-latest
|
2020-10-04 05:33:32 +08:00
|
|
|
outputs:
|
|
|
|
digest: ${{ steps.docker_build.outputs.digest }}
|
2020-10-04 04:44:16 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v2.3.3
|
|
|
|
-
|
|
|
|
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:
|
|
|
|
driver-opts: network=host
|
|
|
|
-
|
|
|
|
name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-ghcache-
|
|
|
|
-
|
|
|
|
name: Erase cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache/*
|
|
|
|
-
|
|
|
|
name: Build and push
|
|
|
|
id: docker_build
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile-multi-golang
|
|
|
|
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
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
-
|
|
|
|
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
|
|
|
|
|
|
|
|
github-cache-hit:
|
2020-08-16 23:55:47 +08:00
|
|
|
runs-on: ubuntu-latest
|
2020-10-04 04:44:16 +08:00
|
|
|
needs: github-cache-first
|
2020-09-05 11:18:15 +08:00
|
|
|
services:
|
|
|
|
registry:
|
|
|
|
image: registry:2
|
|
|
|
ports:
|
|
|
|
- 5000:5000
|
2020-08-16 23:55:47 +08:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2020-09-24 14:25:40 +08:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-08-16 23:55:47 +08:00
|
|
|
-
|
|
|
|
name: Set up QEMU
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-08-16 23:55:47 +08:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-09-09 06:32:40 +08:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-17 01:22:14 +08:00
|
|
|
with:
|
2020-09-04 00:17:27 +08:00
|
|
|
driver-opts: network=host
|
2020-09-02 16:07:11 +08:00
|
|
|
-
|
|
|
|
name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
2020-10-04 04:44:16 +08:00
|
|
|
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
|
2020-09-02 16:07:11 +08:00
|
|
|
restore-keys: |
|
2020-10-04 04:44:16 +08:00
|
|
|
${{ runner.os }}-buildx-ghcache-
|
2020-08-16 23:55:47 +08:00
|
|
|
-
|
|
|
|
name: Build and push
|
2020-08-23 10:07:29 +08:00
|
|
|
id: docker_build
|
2020-08-16 23:55:47 +08:00
|
|
|
uses: ./
|
|
|
|
with:
|
2020-09-02 16:07:11 +08:00
|
|
|
context: ./test
|
|
|
|
file: ./test/Dockerfile-multi-golang
|
2020-08-16 23:55:47 +08:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2020-08-17 04:38:03 +08:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2020-08-17 08:33:38 +08:00
|
|
|
push: true
|
2020-08-16 23:55:47 +08:00
|
|
|
tags: |
|
|
|
|
localhost:5000/name/app:latest
|
|
|
|
localhost:5000/name/app:1.0.0
|
2020-09-02 16:07:11 +08:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
2020-08-17 08:42:46 +08:00
|
|
|
-
|
|
|
|
name: Inspect
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
2020-08-23 10:06:55 +08:00
|
|
|
-
|
|
|
|
name: Image digest
|
|
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
2020-10-04 05:33:32 +08:00
|
|
|
-
|
|
|
|
name: Check digests
|
|
|
|
run: |
|
|
|
|
echo Compare "${{ needs.github-cache-first.outputs.digest }}" with "${{ steps.docker_build.outputs.digest }}"
|
|
|
|
if [ "${{ needs.github-cache-first.outputs.digest }}" != "${{ steps.docker_build.outputs.digest }}" ]; then
|
|
|
|
echo "::error::Digests should be identical"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-09-02 16:07:11 +08:00
|
|
|
-
|
|
|
|
name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
2020-08-16 23:55:47 +08:00
|
|
|
-
|
|
|
|
name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|