Compare commits

...
4 Commits
Author SHA1 Message Date
codex d4e9264e0a Merge branch 'main' into feature/home-ci-cd
CI / build-and-test (pull_request) Skipped
2026-11-24 21:46:33 +00:00
codex 07e4a61449 ci: validate final PR head before merge to main 2026-11-24 21:44:08 +00:00
codex 017887c9e8 ci: restrict image publication to upstream main
CI / build-and-test (pull_request) Canceled after 0s
CI / images (backend, Dockerfile.backend) (pull_request) Canceled after 0s
CI / images (frontend, Dockerfile.frontend) (pull_request) Canceled after 0s
2026-11-18 05:21:38 +00:00
codex 86a564626e ci: verify application and publish container images
CI / build-and-test (pull_request) Canceled after 0s
CI / images (backend, Dockerfile.backend) (pull_request) Canceled after 0s
CI / images (frontend, Dockerfile.frontend) (pull_request) Canceled after 0s
2026-11-18 05:18:21 +00:00
2 changed files with 64 additions and 17 deletions

No files matched your search

+9 -17
View File
@@ -1,14 +1,16 @@
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
branches: [main]
types: [edited]
jobs:
build-and-test:
if: >-
contains(github.event.pull_request.body, format('CI-Head: {0}', github.event.pull_request.head.sha))
runs-on: ubuntu-latest
container: node:20-bookworm
services:
postgres:
image: postgres:16-alpine
@@ -16,29 +18,20 @@ jobs:
POSTGRES_DB: calendar_run_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d calendar_run_test"
--health-interval 10s
--health-interval 5s
--health-timeout 5s
--health-retries 5
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: |
backend/package-lock.json
frontend/package-lock.json
persist-credentials: false
- name: Backend — install, build, test
working-directory: backend
env:
NODE_ENV: test
DB_HOST: 127.0.0.1
DB_HOST: postgres
DB_PORT: "5432"
DB_NAME: calendar_run_test
DB_USER: postgres
@@ -48,7 +41,6 @@ jobs:
run: |
npm ci
npm run build
npm run db:migrate
npm test
- name: Frontend — install, build
+55
View File
@@ -0,0 +1,55 @@
name: Publish images
on:
push:
branches: [main]
jobs:
images:
if: github.server_url == 'https://git.vakanaut.ru' && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'admin/runners-calendar'
runs-on: home-publish
strategy:
matrix:
include:
- component: backend
dockerfile: Dockerfile.backend
- component: frontend
dockerfile: Dockerfile.frontend
env:
REGISTRY: git.vakanaut.ru
COMPONENT: ${{ matrix.component }}
DOCKERFILE: ${{ matrix.dockerfile }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Publish Docker image and record its digest
shell: bash
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
REGISTRY_OWNER: ${{ vars.REGISTRY_OWNER }}
run: |
set -euo pipefail
: "${REGISTRY_USERNAME:?set REGISTRY_USERNAME}"
: "${REGISTRY_TOKEN:?set REGISTRY_TOKEN}"
owner="${REGISTRY_OWNER:-$REGISTRY_USERNAME}"
[[ "$owner" =~ ^[a-z0-9][a-z0-9_-]*$ ]]
export DOCKER_CONFIG
DOCKER_CONFIG="$(mktemp -d)"
metadata="$(mktemp)"
trap 'rm -rf -- "$DOCKER_CONFIG"; rm -f -- "$metadata"' EXIT
image="$REGISTRY/$owner/runners-calendar-$COMPONENT"
printf '%s\n' "$REGISTRY_TOKEN" | docker login "$REGISTRY" --username "$REGISTRY_USERNAME" --password-stdin
docker buildx build --file "$DOCKERFILE" --tag "$image:$GITHUB_SHA" \
--label "org.opencontainers.image.revision=$GITHUB_SHA" \
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
--metadata-file "$metadata" --push .
digest="$(jq -er '."containerimage.digest" | select(test("^sha256:[a-f0-9]{64}$"))' "$metadata")"
printf '%s\n' "$image@$digest"
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
printf '%s\n' "$image@$digest" >> "$GITHUB_STEP_SUMMARY"
fi