ci: udrul portalen med et v*-tag
Portalen blev udrullet ved at kopiere filer ind i drift, og drift og git gled fra hinanden. Nu er appmappen i drift en git-checkout, og et v*-tag udruller via Gitea Actions: CD logger ind som deploy-brugeren og kører deploy/deploy.sh fra tagget. Scriptet afbryder hvis drift afviger fra git, installerer requirements kun når de er ændret, og ruller tilbage hvis /healthz ikke svarer efter genstart. Værtsadressen ligger i en repo-variabel. CI kompilerer Python, parser alle templates og tjekker deploy.sh. Claude-Session: https://claude.ai/code/session_012LCTmU2ewo8tnM1dByYAoG
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
name: CD
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
concurrency:
|
||||
group: deploy-prod
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: python:3.11-bookworm
|
||||
steps:
|
||||
- name: Tooling (ssh client)
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq --no-install-recommends openssh-client
|
||||
|
||||
- name: Configure SSH
|
||||
run: |
|
||||
install -d -m700 ~/.ssh
|
||||
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_deploy
|
||||
chmod 600 ~/.ssh/id_deploy
|
||||
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||
env:
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
|
||||
|
||||
- name: Deploy ${{ github.ref_name }}
|
||||
run: |
|
||||
ssh -i ~/.ssh/id_deploy -o IdentitiesOnly=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"cd \"\${PORTAL_DIR:-/opt/portal/app}\" && git fetch --tags --quiet && git show '${TAG}:deploy/deploy.sh' | bash -s -- '${TAG}'"
|
||||
env:
|
||||
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
@@ -0,0 +1,31 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Tooling
|
||||
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends python3 python3-jinja2
|
||||
- name: Python compiles
|
||||
run: python3 -m compileall -q .
|
||||
- name: Templates parse
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import pathlib, jinja2
|
||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader("templates"))
|
||||
for p in sorted(pathlib.Path("templates").glob("*.html")):
|
||||
env.parse(p.read_text())
|
||||
print("templates ok")
|
||||
PY
|
||||
- name: deploy.sh syntax
|
||||
run: bash -n deploy/deploy.sh
|
||||
Reference in New Issue
Block a user