2020-09-08 19:39:48 +00:00
|
|
|
name: ci
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
2020-09-30 20:51:50 +00:00
|
|
|
ci:
|
2020-09-08 19:39:48 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-10 20:26:14 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
dockerfile:
|
|
|
|
- Dockerfile
|
|
|
|
- Dockerfile.web
|
|
|
|
include:
|
|
|
|
- dockerfile: Dockerfile
|
2020-09-10 21:48:21 +00:00
|
|
|
docker-image: localhost:5000/${{ github.event.repository.full_name }}
|
2020-09-10 20:26:14 +00:00
|
|
|
- dockerfile: Dockerfile.web
|
2020-09-10 21:48:21 +00:00
|
|
|
docker-image: localhost:5000/${{ github.event.repository.full_name }}web
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
registry:
|
2020-09-10 22:10:31 +00:00
|
|
|
image: registry:latest
|
2020-09-10 20:26:14 +00:00
|
|
|
ports:
|
|
|
|
- 5000:5000
|
|
|
|
|
2020-09-08 19:39:48 +00:00
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Checkout
|
2020-09-28 22:30:03 +00:00
|
|
|
uses: actions/checkout@v2.3.3
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Prepare
|
2020-09-08 19:39:48 +00:00
|
|
|
id: prep
|
|
|
|
run: |
|
2020-09-10 20:26:14 +00:00
|
|
|
echo ::set-output name=build-date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Set up QEMU
|
2020-10-02 17:01:49 +00:00
|
|
|
uses: docker/setup-qemu-action@v1.0.1
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Set up Docker Buildx
|
2020-09-08 19:39:48 +00:00
|
|
|
id: buildx
|
2020-10-02 17:18:08 +00:00
|
|
|
uses: docker/setup-buildx-action@v1.0.1
|
2020-09-08 19:39:48 +00:00
|
|
|
with:
|
|
|
|
version: latest
|
2020-09-10 22:10:31 +00:00
|
|
|
driver-opts: network=host
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:50:29 +00:00
|
|
|
- name: Available platforms
|
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
|
2020-09-28 06:17:17 +00:00
|
|
|
- name: Get platforms
|
2020-09-28 22:30:03 +00:00
|
|
|
uses: actions/github-script@v3.0.0
|
2020-09-28 06:17:17 +00:00
|
|
|
id: platforms
|
|
|
|
env:
|
|
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
|
|
|
with:
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
|
|
|
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/getDockerPlatforms.js`)
|
|
|
|
return script("${{ matrix.dockerfile }}", "${{ steps.buildx.outputs.platforms }}");
|
|
|
|
|
|
|
|
- name: Platforms
|
|
|
|
run: echo ${{ steps.platforms.outputs.result }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Cache Docker layers
|
2020-09-28 22:30:03 +00:00
|
|
|
uses: actions/cache@v2.1.1
|
2020-09-08 19:39:48 +00:00
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
2020-09-10 20:26:14 +00:00
|
|
|
key: ${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
|
2020-09-08 19:39:48 +00:00
|
|
|
restore-keys: |
|
2020-09-10 20:26:14 +00:00
|
|
|
${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
${{ runner.os }}-docker-${{ matrix.dockerfile }}-
|
|
|
|
${{ runner.os }}-docker-
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 21:52:56 +00:00
|
|
|
- name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Build and push
|
|
|
|
id: docker-build
|
2020-09-08 19:39:48 +00:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
2020-09-10 20:26:14 +00:00
|
|
|
push: true
|
2020-09-08 19:39:48 +00:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: .
|
2020-09-10 20:26:14 +00:00
|
|
|
file: ./${{ matrix.dockerfile}}
|
2020-09-28 06:17:17 +00:00
|
|
|
platforms: ${{ steps.platforms.outputs.result }}
|
2020-09-10 20:26:14 +00:00
|
|
|
tags: ${{ matrix.docker-image }}:${{ github.sha }}
|
2020-09-08 19:39:48 +00:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2020-09-10 17:28:27 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
2020-09-08 19:39:48 +00:00
|
|
|
build-args: |
|
2020-09-10 20:26:14 +00:00
|
|
|
BUILD_DATE=${{ steps.prep.outputs.build-date }}
|
2020-09-08 19:39:48 +00:00
|
|
|
REVISION=${{ github.sha }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Inspect
|
2020-09-08 19:39:48 +00:00
|
|
|
run: |
|
2020-09-10 20:26:14 +00:00
|
|
|
docker buildx imagetools inspect ${{ matrix.docker-image }}:${{ github.sha }}
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker-build.outputs.digest }}
|
2020-09-08 19:39:48 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Dump context
|
|
|
|
if: always()
|
2020-09-28 22:30:03 +00:00
|
|
|
uses: crazy-max/ghaction-dump-context@v1.0.0
|