Add reviewed container release workflow #2
@@ -0,0 +1,13 @@
|
|||||||
|
.git
|
||||||
|
.gitea
|
||||||
|
.cpcache
|
||||||
|
.clj-kondo
|
||||||
|
.env
|
||||||
|
.token
|
||||||
|
.idea
|
||||||
|
log
|
||||||
|
node_modules
|
||||||
|
resources/public/css/output.css
|
||||||
|
target
|
||||||
|
*.iml
|
||||||
|
*.log
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
tags: ['v*']
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: harbor.pmagnus.cloud
|
||||||
|
IMAGE: harbor.pmagnus.cloud/elprice/elprice
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: elprice
|
||||||
|
POSTGRES_USER: elprice
|
||||||
|
POSTGRES_PASSWORD: elprice
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U elprice -d elprice"
|
||||||
|
--health-interval 2s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 30
|
||||||
|
env:
|
||||||
|
TARGET_HOST: localhost
|
||||||
|
TARGET_PORT: "5432"
|
||||||
|
TARGET_DB: elprice
|
||||||
|
TARGET_USER: elprice
|
||||||
|
TARGET_PASSWORD: elprice
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: clojure -M:test
|
||||||
|
|
||||||
|
- name: Generate immutable tags
|
||||||
|
id: tags
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SHA=$(git rev-parse --short HEAD)
|
||||||
|
case "$GITHUB_REF" in
|
||||||
|
refs/tags/v*) VERSION="${GITHUB_REF_NAME#v}" ;;
|
||||||
|
*) VERSION="main-$(date -u +%Y%m%d%H%M%S)" ;;
|
||||||
|
esac
|
||||||
|
echo "primary=$IMAGE:$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "qualified=$IMAGE:$VERSION-$SHA" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# The runner host has the pinned route to Harbor. Keep BuildKit on the
|
||||||
|
# host network until job containers can resolve and reach it directly.
|
||||||
|
- uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
|
||||||
|
- uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.HARBOR_ROBOT_USER }}
|
||||||
|
password: ${{ secrets.HARBOR_ROBOT_TOKEN }}
|
||||||
|
|
||||||
|
- uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.tags.outputs.primary }}
|
||||||
|
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
|
||||||
|
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
|
||||||
|
|
||||||
|
- name: Wait for Harbor policy, then add SHA tag
|
||||||
|
env:
|
||||||
|
PRIMARY: ${{ steps.tags.outputs.primary }}
|
||||||
|
QUALIFIED: ${{ steps.tags.outputs.qualified }}
|
||||||
|
run: |
|
||||||
|
for attempt in $(seq 1 60); do
|
||||||
|
if docker buildx imagetools inspect "$PRIMARY" >/dev/null 2>&1; then
|
||||||
|
docker buildx imagetools create --tag "$QUALIFIED" "$PRIMARY"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "waiting for Harbor scan/pull policy ($attempt/60)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
echo "Harbor did not approve $PRIMARY within 10 minutes" >&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: echo "pushed ${{ steps.tags.outputs.primary }} and ${{ steps.tags.outputs.qualified }}"
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
name: pull-request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: elprice
|
||||||
|
POSTGRES_USER: elprice
|
||||||
|
POSTGRES_PASSWORD: elprice
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U elprice -d elprice"
|
||||||
|
--health-interval 2s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 30
|
||||||
|
env:
|
||||||
|
TARGET_HOST: localhost
|
||||||
|
TARGET_PORT: "5432"
|
||||||
|
TARGET_DB: elprice
|
||||||
|
TARGET_USER: elprice
|
||||||
|
TARGET_PASSWORD: elprice
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: clojure -M:test
|
||||||
|
|
||||||
|
- name: Build production image
|
||||||
|
run: docker build --platform linux/amd64 -t elprice:pr-check .
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
(ns pmagnus.elprice.core-test
|
(ns pmagnus.elprice.core-test
|
||||||
(:require
|
(:require
|
||||||
[pmagnus.elprice.test-utils :as utils]
|
[clojure.test :refer [deftest is]]
|
||||||
[clojure.test :refer :all]))
|
[pmagnus.elprice.core :as core]))
|
||||||
|
|
||||||
(deftest example-test
|
|
||||||
(is (= 1 2)))
|
|
||||||
|
|
||||||
|
(deftest system-state-is-managed-in-an-atom
|
||||||
|
(is (instance? clojure.lang.Atom core/system)))
|
||||||
|
|||||||
Reference in New Issue
Block a user