56 lines
2.3 KiB
YAML
56 lines
2.3 KiB
YAML
name: Build and push container image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04-node
|
|
steps:
|
|
- name: Set up Docker environment
|
|
run: |
|
|
apt update && apt upgrade -y && apt install -y apt-transport-https ca-certificates curl zstd gnupg lsb-release
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
echo \
|
|
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
|
|
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
apt update && apt install -y docker-ce docker-ce-cli containerd.io
|
|
|
|
- name: Checkout branch
|
|
uses: https://github.com/actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
|
|
|
- name: Login to Gitea
|
|
uses: https://github.com/docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
|
|
with:
|
|
registry: git.toast-server.net
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: https://github.com/docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3
|
|
|
|
- name: Build and push image
|
|
uses: https://github.com/docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: git.toast-server.net/toast/kon:main
|
|
cache-to: type=local,dest=/tmp/.build-cache
|
|
cache-from: type=local,src=/tmp/.buildx-cache,mode=max
|
|
|
|
- name: Container deployment
|
|
uses: https://github.com/appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 # v1.0.3
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USERNAME }}
|
|
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
|
key: ${{ secrets.SSH_KEY }}
|
|
port: ${{ secrets.SSH_PORT }}
|
|
script: |
|
|
cd kon && docker compose pull && \
|
|
docker compose down bot --remove-orphans && docker compose up -d bot && \
|
|
docker image prune -f && docker system prune -f
|