Migrate CI/deploy pipeline from GitHub Actions to Gitea Actions
docker-build-push / build-push-deploy (push) Successful in 33s
docker-build-push / build-push-deploy (push) Successful in 33s
Build/test/push now runs as .gitea/workflows/docker-build-push.yml, pushing to gitea.blairhaus.net/pmb/finger and auto-deploying to mammut and bsd on every push to main, since GitHub is no longer in use. Removes the now-dead .github workflows, .codecov.yml, and their README badges.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
name: docker-build-push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-push-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# act_runner bind-mounts the admin host's real Docker socket into every
|
||||
# job container (Docker-outside-of-Docker, not a nested daemon), so
|
||||
# `docker` here talks straight to the host's daemon — no separate
|
||||
# dockerd to start. The Dockerfile's builder stage runs `meson test`,
|
||||
# so a failing test fails this build before anything gets pushed.
|
||||
- name: Build, test, and push image
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
SHA="${{ github.sha }}"
|
||||
IMAGE="gitea.blairhaus.net/pmb/finger"
|
||||
|
||||
docker build -t "$IMAGE:$SHA" -t "$IMAGE:latest" .
|
||||
printf '%s' "$REGISTRY_TOKEN" | docker login gitea.blairhaus.net -u pmb --password-stdin
|
||||
docker push "$IMAGE:$SHA"
|
||||
docker push "$IMAGE:latest"
|
||||
docker logout gitea.blairhaus.net
|
||||
|
||||
echo "pushed $IMAGE:$SHA and $IMAGE:latest"
|
||||
|
||||
# Deploy: hop into the admin host itself (job containers can only reach
|
||||
# host.docker.internal directly), then from there reuse admin's own
|
||||
# already-configured `ssh mammut`/`ssh bsd` aliases to reach the two
|
||||
# real deploy targets.
|
||||
- name: Deploy to mammut and bsd
|
||||
env:
|
||||
ADMIN_HOST_SSH_KEY: ${{ secrets.ADMIN_HOST_SSH_KEY }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "$ADMIN_HOST_SSH_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -H host.docker.internal >> ~/.ssh/known_hosts 2>/dev/null
|
||||
|
||||
scp -i ~/.ssh/id_ed25519 update-fingerd.sh [email protected]:/tmp/update-fingerd.sh
|
||||
|
||||
ssh -i ~/.ssh/id_ed25519 [email protected] bash -s <<'EOF'
|
||||
set -euo pipefail
|
||||
ssh mammut "cd ~/finger && docker compose pull && docker compose up -d" < /dev/null
|
||||
ssh bsd 'sh -s' < /tmp/update-fingerd.sh
|
||||
rm -f /tmp/update-fingerd.sh
|
||||
EOF
|
||||
|
||||
echo "deployed to mammut + bsd"
|
||||
Reference in New Issue
Block a user