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.
69 lines
2.1 KiB
YAML
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."
|