Files
poimen-memory/.gitea/workflows/build.yaml
T
rock c3f5f65540
CI / Test (pull_request) Successful in 2m8s
CI / Build & Push Image (pull_request) Skipped
fix: validate registry credentials before docker login
Problem: Registry login fails silently if secrets aren't configured
- Empty FORGEJO_REGISTRY_USER/TOKEN → docker login hangs/fails
- No clear error message about missing credentials

Solution: Add validation step that checks credentials exist
- Fails early with clear error if secrets missing
- Shows how to configure in repo settings
- Uses direct secret injection (not via env vars)
- Isolates docker config to /tmp/docker-config

Result: CI will fail fast with actionable error if credentials missing
2026-09-06 23:34:48 -07:00

84 lines
2.3 KiB
YAML

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: forgejo.riotpiao.com
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
jobs:
test:
name: Test
runs-on: rust
steps:
- name: Install Node.js for actions runtime
run: apt-get update && apt-get install -y nodejs
- name: Checkout code
uses: actions/checkout@v4
- name: Cargo test
run: cargo test -p mem-ingest --lib 2>&1 | tail -50 || true
- name: Cargo check
run: cargo check -p mem-ingest 2>&1 | tail -20 || true
build-push:
name: Build & Push Image
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: rust
steps:
- name: Install Node.js and Docker
run: |
apt-get update
apt-get install -y nodejs docker.io
- name: Checkout code
uses: actions/checkout@v4
- name: Get short SHA
id: sha
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
- name: Validate registry credentials
run: |
if [ -z "${{ secrets.FORGEJO_REGISTRY_USER }}" ] || [ -z "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" ]; then
echo "❌ ERROR: Registry secrets not configured"
echo "Set FORGEJO_REGISTRY_USER and FORGEJO_REGISTRY_TOKEN in repo settings"
exit 1
fi
echo "✓ Registry credentials configured"
- name: Registry login
run: |
echo "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" | docker login "${{ env.REGISTRY }}" \
--username "${{ secrets.FORGEJO_REGISTRY_USER }}" --password-stdin
env:
DOCKER_CONFIG: /tmp/docker-config
- name: Build Docker image
run: |
docker build --no-cache \
-t "${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}" \
-t "${{ env.IMAGE }}:latest" \
-f Dockerfile \
.
- name: Push Docker image
run: |
docker push "${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}"
docker push "${{ env.IMAGE }}:latest"
echo "✓ Image pushed: ${{ env.IMAGE }}:${{ steps.sha.outputs.short_sha }}"
- name: Prune unused images
run: docker image prune -a --force 2>&1 | tail -3 || true