dyzur-bot/.forgejo/workflows/ci.yml

40 lines
1.3 KiB
YAML

name: Build and push Docker image
# Build + push only. The deploy target (kamash-01) is NOT the host the Forgejo
# runner lives on (Dembian), so the runner cannot `compose up` there — unlike
# sprzatansko-bot, which is co-located with the runner. Deployment is owned by
# Ansible (kamnet: playbooks/dyzur-bot.yml), whose systemd unit pulls :latest on
# (re)start. To roll out a new image after CI: re-run that playbook or
# `systemctl restart dyzur-bot` on kamash-01.
on:
push:
branches:
- main
jobs:
build:
runs-on: docker
container: golang:1.26-alpine
steps:
- name: Install tools
run: apk add --no-cache git docker-cli
- name: Checkout
run: git clone ${{ github.server_url }}/${{ github.repository }} . && git checkout ${{ github.sha }}
- name: Run tests
run: go test ./...
- name: Log in to container registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.kambr.pl -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build and push
run: |
docker build \
-t git.kambr.pl/kamash/dyzur-bot:latest \
-t git.kambr.pl/kamash/dyzur-bot:${{ github.sha }} \
.
docker push git.kambr.pl/kamash/dyzur-bot:latest
docker push git.kambr.pl/kamash/dyzur-bot:${{ github.sha }}