2024-09-21 12:49:01 -04:00
|
|
|
name: Build and push Docker 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
|
|
|
|
2024-09-21 12:49:01 -04:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
jobs:
|
|
|
|
build:
|
2024-08-14 22:28:23 -04:00
|
|
|
runs-on: ubuntu-22.04
|
2024-09-21 13:44:55 -04:00
|
|
|
env:
|
|
|
|
RUNNER_TOOL_CACHE: /toolcache
|
2024-09-21 12:49:01 -04:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
steps:
|
2024-09-21 12:49:01 -04:00
|
|
|
- name: Set up Docker Buildx
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
|
2024-09-21 12:49:01 -04:00
|
|
|
|
|
|
|
- name: Checkout
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
|
|
|
|
|
|
- run: sudo apt-get update && sudo apt-get install -y zstd
|
2024-01-07 07:02:43 -05:00
|
|
|
|
2024-09-21 12:49:01 -04:00
|
|
|
- name: Cache
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
|
2024-09-21 12:49:01 -04:00
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
$HOME/.cargo/bin/
|
|
|
|
$HOME/.cargo/git/
|
|
|
|
$HOME/.cargo/registry/index/
|
|
|
|
$HOME/.cargo/registry/cache/
|
|
|
|
target/
|
|
|
|
key: ${{ runner.os }}-cache-${{ hashFiles('./Cargo.lock') }}
|
2024-09-21 14:17:36 -04:00
|
|
|
restore-keys: ${{ runner.os }}-cache-
|
2024-09-21 12:49:01 -04:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
- name: Login to Gitea
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
|
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-09-21 12:49:01 -04:00
|
|
|
- name: Set up Rust toolchain
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
|
2024-09-21 12:49:01 -04:00
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
rustflags: -C target-feature=-crt-static
|
|
|
|
|
|
|
|
- name: Install zigbuild
|
|
|
|
run: |
|
2024-09-21 14:17:36 -04:00
|
|
|
pip3 install ziglang
|
2024-09-21 12:49:01 -04:00
|
|
|
cargo install --locked cargo-zigbuild
|
|
|
|
|
|
|
|
- name: Compile
|
|
|
|
run: |
|
|
|
|
rustup target add x86_64-unknown-linux-musl
|
|
|
|
export GIT_COMMIT_HASH=${{ github.sha }} && \
|
|
|
|
export GIT_COMMIT_BRANCH=${{ github.ref_name }} && \
|
|
|
|
cargo zigbuild --target x86_64-unknown-linux-musl --locked -rF production
|
2024-01-07 08:28:30 -05:00
|
|
|
|
2023-12-08 06:25:57 -05:00
|
|
|
- name: Build and push image
|
2024-09-21 14:17:36 -04:00
|
|
|
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.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
|
2024-09-21 12:49:01 -04:00
|
|
|
tags: git.toast-server.net/toast/kon:master
|
2024-09-21 14:17:36 -04:00
|
|
|
cache-from: type=registry,ref=git.toast-server.net/toast/kon:cache
|
|
|
|
cache-to: type=registry,ref=git.toast-server.net/toast/kon:cache,mode=max,image-manifest=true,oci-mediatypes=true
|
|
|
|
|
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-09-21 14:17:36 -04:00
|
|
|
uses: appleboy/ssh-action@d732991ab09097d8c8f390d91385b0386e619598 # v1.0.3
|
2024-03-10 19:30:52 -04:00
|
|
|
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-08-14 22:58:26 -04:00
|
|
|
docker compose up -d bot --force-recreate && \
|
|
|
|
docker system prune -f
|