Deploy the CI-built wheel for the triggering SHA so the UI and\nbuild metadata stay in sync in production.
79 lines
2.5 KiB
YAML
79 lines
2.5 KiB
YAML
name: Deploy live
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
concurrency:
|
|
group: importarr-live
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
cache-dependency-path: frontend/package-lock.json
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install '.[test]'
|
|
npm --prefix frontend ci
|
|
- name: Test and build
|
|
run: |
|
|
python -m pytest -q
|
|
npm --prefix frontend test -- --run
|
|
npm --prefix frontend run build
|
|
python -m pip wheel --no-deps --wheel-dir dist .
|
|
sh -n deploy/systemd-install.sh
|
|
sh -n deploy/repo-upgrade.sh
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: importarr-wheel
|
|
path: dist/*.whl
|
|
|
|
deploy:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: importarr-wheel
|
|
path: dist
|
|
- name: Configure deployment SSH
|
|
shell: bash
|
|
env:
|
|
DEPLOY_KEY: ${{ secrets.IMPORTARR_DEPLOY_SSH_KEY }}
|
|
KNOWN_HOSTS: ${{ secrets.IMPORTARR_DEPLOY_KNOWN_HOSTS }}
|
|
run: |
|
|
install -d -m 0700 ~/.ssh
|
|
install -m 0600 /dev/null ~/.ssh/id_ed25519
|
|
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/id_ed25519
|
|
printf '%s\n' "$KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
|
|
- name: Deploy origin/main
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.IMPORTARR_DEPLOY_HOST }}
|
|
DEPLOY_PORT: ${{ secrets.IMPORTARR_DEPLOY_PORT }}
|
|
DEPLOY_USER: ${{ secrets.IMPORTARR_DEPLOY_USER }}
|
|
DEPLOY_SHA: ${{ github.sha }}
|
|
run: |
|
|
WHEEL=$(find dist -maxdepth 1 -name 'importarr-*.whl' -print -quit)
|
|
test -n "$WHEEL"
|
|
scp -P "$DEPLOY_PORT" -o BatchMode=yes "$WHEEL" "$DEPLOY_USER@$DEPLOY_HOST:/tmp/importarr-deploy.whl"
|
|
ssh -p "$DEPLOY_PORT" -o BatchMode=yes "$DEPLOY_USER@$DEPLOY_HOST" \
|
|
"deploy_status=0; sudo -n /bin/sh -c 'set -eu; cd /opt/importarr/repo;
|
|
test -z \"\$(git status --porcelain)\";
|
|
git fetch --prune origin main;
|
|
git checkout --detach $DEPLOY_SHA;
|
|
/bin/sh deploy/repo-upgrade.sh /tmp/importarr-deploy.whl $DEPLOY_SHA' || deploy_status=\$?;
|
|
rm -f /tmp/importarr-deploy.whl;
|
|
exit \$deploy_status"
|