mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
69 lines
2.2 KiB
YAML
69 lines
2.2 KiB
YAML
name: Reusable Image Builder
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
dockerfile:
|
|
required: true
|
|
type: string
|
|
build-json:
|
|
required: true
|
|
type: string
|
|
build-args:
|
|
required: false
|
|
default: ""
|
|
type: string
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ fromJSON(inputs.build-json).name }}-${{ fromJSON(inputs.build-json).version }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build-image:
|
|
name: Build ${{ fromJSON(inputs.build-json).name }} @ ${{ fromJSON(inputs.build-json).version }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Login to Github Container Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
-
|
|
name: Determine if build needed
|
|
id: build-skip-check
|
|
run: |
|
|
if ! docker manifest inspect ${{ fromJSON(inputs.build-json).image_tag }} &> /dev/null ; then
|
|
echo "Building, no image exists with this version"
|
|
echo ::set-output name=image-exists::false
|
|
else
|
|
echo "Not building, image exists with this version"
|
|
echo ::set-output name=image-exists::true
|
|
fi
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
if: ${{ steps.build-skip-check.outputs.image-exists == 'false' }}
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
if: ${{ steps.build-skip-check.outputs.image-exists == 'false' }}
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
if: ${{ steps.build-skip-check.outputs.image-exists == 'false' }}
|
|
-
|
|
name: Build ${{ fromJSON(inputs.build-json).name }}
|
|
uses: docker/build-push-action@v2
|
|
if: ${{ steps.build-skip-check.outputs.image-exists == 'false' }}
|
|
with:
|
|
context: .
|
|
file: ${{ inputs.dockerfile }}
|
|
tags: ${{ fromJSON(inputs.build-json).image_tag }}
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
build-args: ${{ inputs.build-args }}
|
|
push: true
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|