Refactor build workflow
This commit is contained in:
@@ -2,7 +2,7 @@ name: Build Docker image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: 0 12 * * *
|
- cron: 0 12 */7 * *
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/build-images.yml'
|
- '.github/workflows/build-images.yml'
|
||||||
@@ -14,12 +14,23 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
act-base:
|
print-date:
|
||||||
name: Build base docker images for act
|
name: Provides current date
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
date: ${{ steps.print-date.outputs.date }}
|
||||||
|
steps:
|
||||||
|
- name: Print date in UTC format
|
||||||
|
id: print-date
|
||||||
|
run: echo "::set-output name=date::$(date +%Y%m%d)"
|
||||||
|
act-base:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-${{ matrix.DISTRIB_RELEASE }}
|
||||||
|
needs:
|
||||||
|
- print-date
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: true
|
||||||
max-parallel: 12
|
max-parallel: 6
|
||||||
matrix:
|
matrix:
|
||||||
DISTRIB_ID: [ubuntu]
|
DISTRIB_ID: [ubuntu]
|
||||||
DISTRIB_RELEASE: [latest, 20.04, 18.04, 16.04]
|
DISTRIB_RELEASE: [latest, 20.04, 18.04, 16.04]
|
||||||
@@ -35,6 +46,7 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
|
id: ghcr
|
||||||
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -43,6 +55,7 @@ jobs:
|
|||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Quay
|
- name: Login to Quay
|
||||||
|
id: quay
|
||||||
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -51,21 +64,20 @@ jobs:
|
|||||||
password: ${{ secrets.QUAY_TOKEN }}
|
password: ${{ secrets.QUAY_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
|
id: dckr
|
||||||
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: catthehacker
|
username: catthehacker
|
||||||
password: ${{ secrets.DCKR_TOKEN }}
|
password: ${{ secrets.DCKR_TOKEN }}
|
||||||
|
|
||||||
- name: Check which version is currently `ubuntu-latest`
|
- name: Set Ubuntu version to RELEASE
|
||||||
id: ubuntu_latest
|
id: release
|
||||||
if: ${{ matrix.DISTRIB_RELEASE == 'latest' }}
|
run: echo "::set-output name=RELEASE::$(lsb_release -sr)"
|
||||||
run: echo "::set-output name=UBUNTU_LATEST::$(lsb_release -sr)"
|
|
||||||
|
|
||||||
- name: Build and push ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
- name: Build and push catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
id: docker_build_version
|
id: docker_build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
if: ${{ matrix.DISTRIB_RELEASE != 'latest' }}
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
@@ -73,33 +85,21 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
||||||
|
ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
quay.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
quay.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
||||||
|
quay.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
docker.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
docker.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
||||||
|
docker.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
build-args: |
|
build-args: |
|
||||||
DISTRIB_ID=${{ matrix.DISTRIB_ID }}
|
DISTRIB_ID=${{ matrix.DISTRIB_ID }}
|
||||||
DISTRIB_RELEASE=${{ matrix.DISTRIB_RELEASE }}
|
DISTRIB_RELEASE=${{ steps.release.outputs.RELEASE }}
|
||||||
NODE_VERSION=${{ matrix.NODE_VERSION }}
|
|
||||||
|
|
||||||
- name: Build and push ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
|
||||||
id: docker_build_latest
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
if: ${{ matrix.DISTRIB_RELEASE == 'latest' }}
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
|
||||||
file: ./linux/${{ matrix.DISTRIB_ID }}/${{ matrix.IMAGE_TYPE }}/Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
tags: |
|
|
||||||
ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
|
||||||
quay.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
|
||||||
docker.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
|
||||||
build-args: |
|
|
||||||
DISTRIB_ID=${{ matrix.DISTRIB_ID }}
|
|
||||||
DISTRIB_RELEASE=${{ steps.ubuntu_latest.outputs.UBUNTU_LATEST }}
|
|
||||||
NODE_VERSION=${{ matrix.NODE_VERSION }}
|
NODE_VERSION=${{ matrix.NODE_VERSION }}
|
||||||
scan:
|
scan:
|
||||||
|
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
|
name: Scan
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
|
- print-date
|
||||||
- act-base
|
- act-base
|
||||||
strategy:
|
strategy:
|
||||||
max-parallel: 4
|
max-parallel: 4
|
||||||
@@ -111,4 +111,25 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: azure/container-scan@v0
|
- uses: azure/container-scan@v0
|
||||||
with:
|
with:
|
||||||
image-name: ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}
|
image-name: ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
|
measure:
|
||||||
|
if: ${{ github.event_name != 'pull_request' && github.event_name != 'push' }}
|
||||||
|
name: Measure
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- print-date
|
||||||
|
- act-base
|
||||||
|
strategy:
|
||||||
|
max-parallel: 4
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
DISTRIB_ID: [ubuntu]
|
||||||
|
DISTRIB_RELEASE: [latest, 20.04, 18.04, 16.04]
|
||||||
|
IMAGE_TYPE: [act, runner]
|
||||||
|
steps:
|
||||||
|
- name: Install `dive`
|
||||||
|
run: |
|
||||||
|
wget https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb
|
||||||
|
sudo dpkg -i dive_0.9.2_linux_amd64.deb
|
||||||
|
- name: Scan images size
|
||||||
|
run: dive --lowestEfficiency 0 --highestUserWastedPercent 1 ghcr.io/catthehacker/${{ matrix.DISTRIB_ID }}:${{ matrix.IMAGE_TYPE }}-${{ matrix.DISTRIB_RELEASE }}-${{ needs.print-date.outputs.date }}
|
||||||
|
|||||||
Reference in New Issue
Block a user