toast
3f52c785c3
Some checks failed
Build and push container image / build (push) Has been cancelled
71 lines
2.6 KiB
YAML
71 lines
2.6 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: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
|
|
|
- name: Login to Gitea
|
|
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3
|
|
with:
|
|
registry: git.toast-server.net
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Restore from cache
|
|
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
|
|
id: restore-cache
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: docker-buildx-kon-
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Cache cargo build
|
|
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
|
with:
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: git.toast-server.net/toast/kon:main
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Save to cache
|
|
uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
|
|
id: cache
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: docker-buildx-kon-${{ github.sha }}
|