73 lines
2.1 KiB
YAML
73 lines
2.1 KiB
YAML
name: Build and publish container
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out source
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Sign in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.us2plus2.com
|
|
username: ${{ secrets.GITEA_REGISTRY_USERNAME }}
|
|
password: ${{ secrets.GITEA_REGISTRY_TOKEN }}
|
|
|
|
- name: Generate image tags
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: git.us2plus2.com/marvin/site-gateway
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern={{version}}
|
|
type=raw,value=alpha,enable=${{ startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-alpha.') }}
|
|
type=sha
|
|
|
|
- name: Build local smoke-test image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: site-gateway:smoke-test
|
|
cache-from: type=gha
|
|
|
|
- name: Verify Node and built-in SQLite
|
|
run: docker run --rm --entrypoint node site-gateway:smoke-test --input-type=module -e "import { DatabaseSync } from 'node:sqlite'; const db = new DatabaseSync(':memory:'); db.exec('CREATE TABLE smoke (id INTEGER)'); db.close();"
|
|
|
|
- name: Scan image for vulnerabilities
|
|
uses: aquasecurity/trivy-action@0.35.0
|
|
with:
|
|
image-ref: site-gateway:smoke-test
|
|
severity: CRITICAL,HIGH
|
|
exit-code: "0"
|
|
format: table
|
|
|
|
- name: Build and publish
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|