Add GitHub Actions CI and image release (#184)
Releases and CI move to GitHub Actions on the IUCLabs mirror; runners there have no Docker daemon, so images are built daemonless and published to GHCR. - Add `ci.yml`: pre-commit, go vet + golangci-lint (new issues only), tests, build, ko image check, UI build - Add `release.yml`: on `v[0-9]*` tags, push `ghcr.io/iuclabs/artifactapi-ui` (`scripts/ui-image.sh` layers `ui/dist` + nginx conf onto digest-pinned `nginx:alpine`), then `ghcr.io/iuclabs/artifactapi` via ko (distroless static nonroot, version ldflag) - Both images carry `org.opencontainers.image.source`; `latest` moves only after both `vX.Y.Z` tags exist - Pin `ui/Dockerfile.ui` to the same nginx digest - Remove the Woodpecker docker pipeline; PR pipelines stay - Add `.github/CODEOWNERS` for `@IUCLabs/maintainers` Reviewed-on: #184 Co-authored-by: unkin-agent <unkin-agent@unkin.net> Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #184.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* @IUCLabs/maintainers
|
||||
@@ -0,0 +1,79 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
||||
- run: uvx pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
lint:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- run: go vet ./...
|
||||
# existing findings predate this job; gate new code only
|
||||
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
|
||||
with:
|
||||
version: v2.15.0
|
||||
only-new-issues: true
|
||||
|
||||
test:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# runner image has no C toolchain (no -race) and no docker (testcontainers tests skip)
|
||||
- run: go test -count=1 ./pkg/... ./internal/...
|
||||
|
||||
build:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- run: go build ./...
|
||||
- run: go install github.com/google/ko@v0.19.1
|
||||
- run: ko build --push=false --bare --platform linux/amd64 ./cmd/artifactapi
|
||||
env:
|
||||
KO_DOCKER_REPO: ghcr.io/iuclabs/artifactapi
|
||||
VERSION: dev
|
||||
|
||||
ui:
|
||||
runs-on: iuclabs-k8s
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ui
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
cache-dependency-path: ui/package-lock.json
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
env:
|
||||
BASE_PATH: /ui
|
||||
@@ -0,0 +1,49 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v[0-9]*"]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: iuclabs-release
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
cache-dependency-path: ui/package-lock.json
|
||||
- run: |
|
||||
go install github.com/google/ko@v0.19.1
|
||||
go install github.com/google/go-containerregistry/cmd/crane@v0.22.1
|
||||
- run: echo "${GITHUB_TOKEN}" | crane auth login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: npm ci && npm run build
|
||||
working-directory: ui
|
||||
env:
|
||||
BASE_PATH: /ui
|
||||
- name: UI image
|
||||
run: scripts/ui-image.sh "ghcr.io/iuclabs/artifactapi-ui:${GITHUB_REF_NAME}"
|
||||
env:
|
||||
BASE_PATH: /ui
|
||||
- name: API image
|
||||
run: >-
|
||||
ko build --bare --sbom=none --platform linux/amd64 --tags "${GITHUB_REF_NAME}"
|
||||
--image-label org.opencontainers.image.source=https://github.com/IUCLabs/artifactapi
|
||||
./cmd/artifactapi
|
||||
env:
|
||||
KO_DOCKER_REPO: ghcr.io/iuclabs/artifactapi
|
||||
VERSION: ${{ github.ref_name }}
|
||||
- name: Move latest
|
||||
run: |
|
||||
crane tag "ghcr.io/iuclabs/artifactapi-ui:${GITHUB_REF_NAME}" latest
|
||||
crane tag "ghcr.io/iuclabs/artifactapi:${GITHUB_REF_NAME}" latest
|
||||
@@ -0,0 +1,6 @@
|
||||
defaultBaseImage: gcr.io/distroless/static-debian12:nonroot
|
||||
builds:
|
||||
- id: artifactapi
|
||||
main: ./cmd/artifactapi
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Env.VERSION}}
|
||||
@@ -1,48 +0,0 @@
|
||||
when:
|
||||
- event: tag
|
||||
ref: refs/tags/v*
|
||||
|
||||
steps:
|
||||
- name: docker-api
|
||||
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
|
||||
settings:
|
||||
registry: artifactapi.k8s.syd1.au.unkin.net
|
||||
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/artifactapi
|
||||
build_args:
|
||||
VERSION: ${CI_COMMIT_TAG}
|
||||
tags:
|
||||
- ${CI_COMMIT_TAG}
|
||||
- latest
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 4Gi
|
||||
cpu: 2
|
||||
|
||||
- name: docker-web
|
||||
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
|
||||
settings:
|
||||
registry: artifactapi.k8s.syd1.au.unkin.net
|
||||
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/artifactapi-ui
|
||||
dockerfile: ui/Dockerfile.ui
|
||||
context: ui
|
||||
build_args:
|
||||
BASE_PATH: /ui
|
||||
tags:
|
||||
- ${CI_COMMIT_TAG}
|
||||
- latest
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 4Gi
|
||||
cpu: 2
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Daemonless ui/Dockerfile.ui: append the built ui/dist and rendered nginx conf
|
||||
# onto the nginx base. Usage: scripts/ui-image.sh <repo:tag>
|
||||
set -euo pipefail
|
||||
|
||||
# Keep in sync with the FROM in ui/Dockerfile.ui.
|
||||
base=nginx:alpine@sha256:fb4658584bd9a916ffb6f6e365f97c25cfdb2923801f551ea08356e695f14ff7
|
||||
base_path=${BASE_PATH:-/ui}
|
||||
source_url=https://github.com/IUCLabs/artifactapi
|
||||
image=$1
|
||||
|
||||
root=$(mktemp -d)
|
||||
mkdir -p "$root/usr/share/nginx/html" "$root/etc/nginx/conf.d"
|
||||
cp -r ui/dist/. "$root/usr/share/nginx/html/"
|
||||
sed "s|\${BASE_PATH}|${base_path}|g" ui/nginx.conf >"$root/etc/nginx/conf.d/default.conf"
|
||||
tar -C "$root" --owner=0 --group=0 --numeric-owner -cf "$root.tar" usr etc
|
||||
|
||||
crane mutate --platform linux/amd64 "$base" --append "$root.tar" \
|
||||
--label "org.opencontainers.image.source=$source_url" -t "$image"
|
||||
+1
-1
@@ -11,7 +11,7 @@ ARG BASE_PATH=/
|
||||
ENV BASE_PATH=${BASE_PATH}
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
FROM nginx:alpine@sha256:fb4658584bd9a916ffb6f6e365f97c25cfdb2923801f551ea08356e695f14ff7
|
||||
|
||||
ARG BASE_PATH=/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user