mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-11 00:05:36 +02:00
149 lines
5.9 KiB
YAML
149 lines
5.9 KiB
YAML
#Tabs not spaces, you moron :)
|
|
|
|
name: Build nestri-runner
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "containerfiles/runner*.Containerfile"
|
|
- "packages/scripts/**"
|
|
- "packages/server/**"
|
|
- ".github/workflows/runner.yml"
|
|
schedule:
|
|
- cron: 7 0 * * 1,3,6 # Regularly to keep that build cache warm
|
|
push:
|
|
branches: [dev, production]
|
|
paths:
|
|
- "containerfiles/runner*.Containerfile"
|
|
- ".github/workflows/runner.yml"
|
|
- "packages/scripts/**"
|
|
- "packages/server/**"
|
|
tags:
|
|
- v*.*.*
|
|
release:
|
|
types: [created]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: nestrilabs/nestri
|
|
BASE_IMAGE: docker.io/cachyos/cachyos:latest
|
|
|
|
# This makes our release ci quit prematurely
|
|
# concurrency:
|
|
# group: ci-${{ github.ref }}
|
|
# cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-docker-pr:
|
|
name: Build images on PR
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
steps:
|
|
-
|
|
name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
-
|
|
name: Set Swap Space
|
|
uses: pierotofy/set-swap-space@master
|
|
with:
|
|
swap-size-gb: 20
|
|
-
|
|
name: Build images using bake
|
|
uses: docker/bake-action@v6
|
|
env:
|
|
BASE_IMAGE: ${{ env.BASE_IMAGE }}
|
|
with:
|
|
files: |
|
|
./.github/workflows/docker-bake.hcl
|
|
targets: runner
|
|
push: false
|
|
load: true
|
|
|
|
build-and-push-docker:
|
|
name: Build and push images
|
|
if: ${{ github.ref == 'refs/heads/production' || github.ref == 'refs/heads/dev' }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
strategy:
|
|
matrix:
|
|
variant:
|
|
- { suffix: "", base: "docker.io/cachyos/cachyos:latest" }
|
|
- { suffix: "-v3", base: "docker.io/cachyos/cachyos-v3:latest" }
|
|
#- { suffix: "-v4", base: "docker.io/cachyos/cachyos-v4:latest" } # Disabled until GHA has this
|
|
steps:
|
|
-
|
|
name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
-
|
|
name: Log into registry ${{ env.REGISTRY }}
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ github.token }}
|
|
-
|
|
name: Extract runner metadata
|
|
id: meta-runner
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner
|
|
tags: |
|
|
type=raw,value=nightly${{ matrix.variant.suffix }},enable={{is_default_branch}}
|
|
type=raw,value={{branch}}${{ matrix.variant.suffix }}
|
|
type=raw,value=latest${{ matrix.variant.suffix }},enable=${{ github.ref == format('refs/heads/{0}', 'production') }}
|
|
type=semver,pattern={{version}}${{ matrix.variant.suffix }}
|
|
type=semver,pattern={{major}}.{{minor}}${{ matrix.variant.suffix }}
|
|
type=semver,pattern={{major}}${{ matrix.variant.suffix }}
|
|
-
|
|
name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
-
|
|
name: Set Swap Space
|
|
uses: pierotofy/set-swap-space@master
|
|
with:
|
|
swap-size-gb: 20
|
|
-
|
|
name: Build and push runner-base image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: containerfiles/runner-base.Containerfile
|
|
context: ./
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner-base:latest${{ matrix.variant.suffix }}
|
|
build-args: |
|
|
BASE_IMAGE=${{ matrix.variant.base }}
|
|
cache-from: type=gha,scope=runner-base${{ matrix.variant.suffix }},mode=max
|
|
cache-to: type=gha,scope=runner-base${{ matrix.variant.suffix }},mode=max
|
|
pull: ${{ github.event_name == 'schedule' }}
|
|
-
|
|
name: Build and push runner-builder image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: containerfiles/runner-builder.Containerfile
|
|
context: ./
|
|
push: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner-builder:latest${{ matrix.variant.suffix }}
|
|
build-args: |
|
|
RUNNER_BASE_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner-base:latest${{ matrix.variant.suffix }}
|
|
cache-from: type=gha,scope=runner-builder${{ matrix.variant.suffix }},mode=max
|
|
cache-to: type=gha,scope=runner-builder${{ matrix.variant.suffix }},mode=max
|
|
-
|
|
name: Build and push runner image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: containerfiles/runner.Containerfile
|
|
context: ./
|
|
push: true
|
|
tags: ${{ steps.meta-runner.outputs.tags }}
|
|
labels: ${{ steps.meta-runner.outputs.labels }}
|
|
build-args: |
|
|
RUNNER_BASE_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner-base:latest${{ matrix.variant.suffix }}
|
|
RUNNER_BUILDER_IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner-builder:latest${{ matrix.variant.suffix }}
|
|
cache-from: type=gha,scope=runner${{ matrix.variant.suffix }},mode=max
|
|
cache-to: type=gha,scope=runner${{ matrix.variant.suffix }},mode=max
|