Files
site-gateway/.github/workflows/container.yml
T
marvin 454d2dc8f7
Build and publish container / publish (push) Has been cancelled
Replace flaky git-based Trivy installer with pinned binary curl (v0.16.76)
2026-09-21 15:41:25 -04:00

77 lines
2.4 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.REGISTRY_USERNAME }}
password: ${{ secrets.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: Install Trivy
run: |
set -e
TRIVY_VERSION=0.56.2
curl -sfL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -o /tmp/trivy.tar.gz
tar -xzf /tmp/trivy.tar.gz -C /tmp trivy
sudo mv /tmp/trivy /usr/local/bin/trivy
trivy --version
- name: Scan image for vulnerabilities
run: trivy image --severity CRITICAL,HIGH --exit-code 0 --format table site-gateway:smoke-test
- 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