36 lines
1.0 KiB
YAML
36 lines
1.0 KiB
YAML
name: Test and deploy MQTT backend
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
concurrency:
|
|
group: mqtt5-test-backend
|
|
cancel-in-progress: false
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Unit tests and vet (no private broker credentials)
|
|
run: docker build --target test -t mqtt5-test-backend-ci:${{ gitea.sha }} .
|
|
deploy:
|
|
needs: test
|
|
if: gitea.event_name != 'pull_request' && gitea.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
volumes:
|
|
- /opt/test-mqtt-5/backend:/runtime
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build and deploy on the existing server Docker daemon
|
|
env:
|
|
COMMIT_SHA: ${{ gitea.sha }}
|
|
MQTT5_RUNTIME: /runtime
|
|
run: |
|
|
set -eu
|
|
TAG="$(date -u +%Y-%m-%d_%H-%M-%S)-$(printf '%s' "$COMMIT_SHA" | cut -c1-12)"
|
|
docker build -t "mqtt5-test-backend:$TAG" .
|
|
sh server/deploy.sh "$TAG"
|