Skip to content

first commit

first commit #1

Workflow file for this run

name: Build-Publish
on:
push:
paths: ['.env', 'Dockerfile', 'rootfs/**', 'patches/**']
workflow_dispatch:
inputs:
no-cache:
description: 'Disable cache'
required: false
default: false
type: boolean
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
# based on
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
jobs:
build:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v3
- name: Get short commit SHA
run: echo "COMMIT=$(git rev-parse --short HEAD)" >>"$GITHUB_ENV"
- name: Get environment from a file
run: cat .env >>"$GITHUB_ENV"
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# https://github.com/docker/metadata-action
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{ is_default_branch }}
# branch
type=ref,event=branch
# version
type=raw,value=${{ env.VERSION }}
# commit
type=sha,prefix=
# https://github.com/docker/login-action
- name: Login to Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/build-push-action
- name: Build and push
id: build
uses: docker/build-push-action@v4
with:
provenance: false
no-cache: ${{ github.event.inputs.no-cache == 'true' }}
build-args: |
BRANCH=${{ env.BRANCH }}
VERSION=${{ env.VERSION }}
COMMIT=${{ env.COMMIT }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}
cache-to: type=inline