2023-12-08 06:25:57 -05:00
|
|
|
name: Build and push container image
|
2024-03-11 23:30:27 -04:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2024-03-11 23:30:27 -04:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
jobs:
|
|
|
|
build:
|
2024-08-14 22:28:23 -04:00
|
|
|
runs-on: ubuntu-22.04
|
2023-12-08 06:25:57 -05:00
|
|
|
steps:
|
2024-01-07 07:24:36 -05:00
|
|
|
- name: Set up Docker environment
|
|
|
|
run: |
|
2024-01-07 09:12:00 -05:00
|
|
|
apt update && apt upgrade -y && apt install -y apt-transport-https ca-certificates curl zstd gnupg lsb-release
|
2024-01-07 07:24:36 -05:00
|
|
|
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
|
2024-01-07 09:12:00 -05:00
|
|
|
apt update && apt install -y docker-ce docker-ce-cli containerd.io
|
2024-01-07 07:02:43 -05:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
- name: Checkout branch
|
2024-08-01 00:47:39 -04:00
|
|
|
uses: https://github.com/actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2024-01-07 07:02:43 -05:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
- name: Login to Gitea
|
2024-08-01 00:45:16 -04:00
|
|
|
uses: https://github.com/docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
|
2023-12-08 06:25:57 -05:00
|
|
|
with:
|
|
|
|
registry: git.toast-server.net
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
2024-01-07 07:02:43 -05:00
|
|
|
|
2024-01-07 08:28:30 -05:00
|
|
|
- name: Set up Docker Buildx
|
2024-08-01 00:46:45 -04:00
|
|
|
uses: https://github.com/docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
|
2024-01-07 08:28:30 -05:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
- name: Build and push image
|
2024-08-01 00:48:37 -04:00
|
|
|
uses: https://github.com/docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
|
2023-12-08 06:25:57 -05:00
|
|
|
with:
|
2024-01-07 11:37:48 -05:00
|
|
|
context: .
|
2023-12-08 06:25:57 -05:00
|
|
|
platforms: linux/amd64
|
|
|
|
push: true
|
|
|
|
tags: git.toast-server.net/toast/kon:main
|
2024-08-08 02:58:47 -04:00
|
|
|
build-args: GIT_HASH=${{ env.GITHUB_SHA }}
|
2024-08-14 22:48:08 -04:00
|
|
|
cache-from: type=registry,ref=git.toast-server.net/toast/kon:main
|
|
|
|
cache-to: type=inline
|
2024-01-07 11:37:48 -05:00
|
|
|
|
2024-08-14 22:28:23 -04:00
|
|
|
deploy:
|
|
|
|
runs-on: alpine-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
2024-05-02 15:26:05 -04:00
|
|
|
- name: Deploy update
|
2024-03-10 19:30:52 -04:00
|
|
|
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: |
|
2024-04-08 18:08:37 -04:00
|
|
|
cd kon && docker compose pull bot && \
|
2024-07-19 19:56:58 -04:00
|
|
|
docker compose down bot && docker compose up -d bot && \
|
2024-03-10 19:30:52 -04:00
|
|
|
docker image prune -f && docker system prune -f
|