elektrine-haraka/.forgejo/workflows/ci-deploy.yml
Maxfield Luke c72f9e9711
All checks were successful
CI and publish / Test (push) Successful in 20s
CI and publish / Build and push image (push) Successful in 6s
ci: publish image only; Elektrine rolls production Haraka
Drop SSH deploy from this repo. Forgejo Actions tests and pushes
git.elektrine.com/elektrine/elektrine-haraka; Elektrine deploy pulls and
restarts the sibling compose stack.
2026-07-29 04:47:12 -04:00

69 lines
2.1 KiB
YAML

# Forgejo Actions: test + build/push image only.
# Production roll is owned by Elektrine deploy (pulls :latest and restarts Haraka).
# Secrets: REGISTRY_USER, REGISTRY_TOKEN
name: CI and publish
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: haraka-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
REGISTRY: git.elektrine.com
IMAGE_NAME: elektrine/elektrine-haraka
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: https://data.forgejo.org/actions/checkout@v4
- name: Run unit tests
run: |
set -euo pipefail
case "$GITHUB_WORKSPACE" in
/data/*) HOST_WORKSPACE="/opt/forgejo-runner/data${GITHUB_WORKSPACE#/data}" ;;
*) HOST_WORKSPACE="$GITHUB_WORKSPACE" ;;
esac
test -f "$GITHUB_WORKSPACE/package.json"
docker run --rm --network host \
--volume "$HOST_WORKSPACE:/app" \
--workdir /app \
node:20-bookworm \
bash -lc 'npm ci && npm test'
publish:
name: Build and push image
needs: test
if: >-
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
env:
IMAGE: git.elektrine.com/elektrine/elektrine-haraka:${{ github.sha }}
IMAGE_LATEST: git.elektrine.com/elektrine/elektrine-haraka:latest
steps:
- uses: https://data.forgejo.org/actions/checkout@v4
- name: Log in to Forgejo registry
env:
REG_USER: ${{ secrets.REGISTRY_USER }}
REG_PASS: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -euo pipefail
echo "$REG_PASS" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
- name: Build and push image
run: |
set -euo pipefail
docker build -t "$IMAGE" -t "$IMAGE_LATEST" .
docker push "$IMAGE"
docker push "$IMAGE_LATEST"
echo "Pushed $IMAGE and $IMAGE_LATEST"
echo "Elektrine deploy will pull this image and roll the Haraka stack."