Kon/.gitea/workflows/build.yml

63 lines
2.5 KiB
YAML
Raw Normal View History

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-03-11 23:30:27 -04:00
runs-on: ubuntu-22.04-node
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
2023-12-08 06:25:57 -05:00
- name: Checkout branch
uses: https://github.com/actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
2023-12-08 06:25:57 -05:00
- name: Login to Gitea
uses: https://github.com/docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 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 08:28:30 -05:00
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3
2024-01-07 08:28:30 -05:00
2024-03-25 21:37:21 -04:00
- name: "Add Cargo registry"
run: |
2024-03-25 21:40:27 -04:00
mkdir -p ~/.cargo && \
2024-03-25 21:37:21 -04:00
echo '[registries.gitea]' \
'index = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"' \
2024-03-25 21:38:56 -04:00
'token = "Bearer ${{ secrets.CARGO_TOKEN }}"' >> ~/.cargo/config.toml
2024-03-25 21:37:21 -04:00
2023-12-08 06:25:57 -05:00
- name: Build and push image
uses: https://github.com/docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.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-03-11 20:47:26 -04:00
cache-to: type=local,dest=/tmp/.build-cache
2024-01-07 11:28:59 -05:00
cache-from: type=local,src=/tmp/.buildx-cache,mode=max
2024-01-07 11:37:48 -05:00
2024-03-21 16:59:28 -04:00
- name: Update Delivery
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-03-22 19:28:15 -04:00
cd kon && docker compose pull && \
2024-03-21 16:59:28 -04:00
docker compose down --remove-orphans && docker compose up -d && \
2024-03-10 19:30:52 -04:00
docker image prune -f && docker system prune -f