synclounge/.github/workflows/ci.yml

120 lines
3.6 KiB
YAML
Raw Normal View History

name: ci
on:
push:
2020-09-09 01:55:17 +00:00
branches-ignore:
2020-09-28 22:30:03 +00:00
- master
pull_request:
jobs:
2020-09-10 20:27:26 +00:00
docker:
runs-on: ubuntu-latest
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 }}
- dockerfile: Dockerfile.web
2020-09-10 21:48:21 +00:00
docker-image: localhost:5000/${{ github.event.repository.full_name }}web
services:
registry:
image: registry:latest
ports:
- 5000:5000
steps:
- name: Checkout
2020-09-28 22:30:03 +00:00
uses: actions/checkout@v2.3.3
- name: Prepare
id: prep
run: |
echo ::set-output name=build-date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up QEMU
2020-09-28 23:22:01 +00:00
uses: docker/setup-qemu-action@v1.0.0
- name: Set up Docker Buildx
id: buildx
2020-09-28 23:22:01 +00:00
uses: docker/setup-buildx-action@v1.0.0
with:
version: latest
driver-opts: network=host
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Get platforms
2020-09-28 22:30:03 +00:00
uses: actions/github-script@v3.0.0
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 }}
- name: Cache Docker layers
2020-09-28 22:30:03 +00:00
uses: actions/cache@v2.1.1
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-docker-${{ matrix.dockerfile }}-
${{ runner.os }}-docker-
2020-09-10 21:52:56 +00:00
- name: Cache hit
run: echo ${{ steps.cache.outputs.cache-hit }}
- name: Build and push
id: docker-build
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./${{ matrix.dockerfile}}
platforms: ${{ steps.platforms.outputs.result }}
tags: ${{ matrix.docker-image }}:${{ github.sha }}
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
build-args: |
BUILD_DATE=${{ steps.prep.outputs.build-date }}
REVISION=${{ github.sha }}
- name: Inspect
run: |
docker buildx imagetools inspect ${{ matrix.docker-image }}:${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker-build.outputs.digest }}
2020-09-29 01:14:27 +00:00
- name: Run the local Anchore scan action itself with GitHub Advanced Security code scanning integration enabled
uses: anchore/scan-action@v1.0.9
with:
image-reference: ${{ matrix.docker-image }}:${{ github.sha }}
dockerfile-path: ${{ matrix.dockerfile }}
acs-report-enable: true
include-app-packages: true
- name: Upload Anchore Scan Report
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif
- name: Dump context
if: always()
2020-09-28 22:30:03 +00:00
uses: crazy-max/ghaction-dump-context@v1.0.0