Files
relay/.github/workflows/test-and-deploy.yaml
2024-01-19 20:36:49 +01:00

66 lines
2.3 KiB
YAML

name: deploy on staging.testrun.org, and if that works, on nine.testrun.org
on:
push:
branches:
- main
- staging-ci
jobs:
deploy:
name: deploy on staging.testrun.org, and if that works, on nine.testrun.org
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# disabled for now, we don't want to reset TLS cert, and for testing nine.testrun.org resetting makes less sense
#- name: rebuild staging.testrun.org to have a clean VPS
# run: |
# curl -X POST \
# -H "Authorization: Bearer ${{ secrets.HETZNER_API_TOKEN }}" \
# -H "Content-Type: application/json" \
# -d '{"image":"debian-12"}' \
# "https://api.hetzner.cloud/v1/servers/${{ secrets.STAGING_SERVER_ID }}/actions/rebuild"
- name: initenv
run: scripts/initenv.sh
- name: append venv/bin to PATH
run: echo venv/bin >>$GITHUB_PATH
- name: run formatting checks
run: cmdeploy fmt -v
- name: run deploy-chatmail offline tests
run: pytest --pyargs cmdeploy
- name: prepare SSH connection
run: |
mkdir ~/.ssh
echo "${{ secrets.STAGING_SSH_KEY }}" >> ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "${{ secrets.NINE_HOST_KEY }}" >> ~/.ssh/known_hosts
echo " --- wait until staging.testrun.org VPS is rebuilt --- "
while ! ssh -o ConnectTimeout=180 -o StrictHostKeyChecking=accept-new -v root@staging.testrun.org id -u ; do sleep 1 ; done
ssh -o StrictHostKeyChecking=accept-new -v root@staging.testrun.org id -u
- name: cmdeploy init staging.testrun.org
run: cmdeploy init staging.testrun.org
- name: cmdeploy run
run: cmdeploy run
- name: cmdeploy dns
run: |
echo "${{ secrets.DEFAULT_DNS_ZONE }}" > staging.testrun.org.zone
cmdeploy dns --zonefile staging-additional.zone
cat staging-additional.zone >> staging.testrun.org.zone
scp -o StrictHostKeyChecking=accept-new staging.testrun.org.zone root@ns.testrun.org:/etc/nsd/staging.testrun.org.zone
ssh root@ns.testrun.org nsd-checkzone staging.testrun.org /etc/nsd/staging.testrun.org.zone
ssh root@ns.testrun.org systemctl reload nsd
cmdeploy dns
- name: cmdeploy test
run: cmdeploy test --slow